Add Dockerfile
Change-Id: I299a96042462b39abeaf2d0c9ea9c693528eb6e9
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..0cda020
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,7 @@
+*
+!templates/main.html
+!go.mod
+!go.sum
+!service.go
+!service_test.go
+!LICENSE
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..54afae3
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,35 @@
+# Build stage
+FROM golang:latest as build
+WORKDIR /src
+
+COPY go.mod go.sum ./
+RUN go mod download
+
+COPY . /src
+
+RUN apt-get update && \
+ apt-get upgrade -y ca-certificates
+
+RUN go test .
+
+RUN go build -o /src/kalamar-plugin-externalresources .
+
+# Main stage
+FROM busybox:glibc
+
+EXPOSE 5722
+
+WORKDIR /
+
+COPY --from=build /etc/ssl/certs /etc/ssl/certs
+COPY --from=build /src/kalamar-plugin-externalresources /kalamar-plugin-externalresources
+COPY --from=build /src/templates /templates
+
+ENTRYPOINT [ "./kalamar-plugin-externalresources" ]
+
+LABEL maintainer="korap@ids-mannheim.de"
+LABEL description="Docker Image for Kalamar-Plugin-ExternalResources, a frontend plugin to link texts to external resources"
+LABEL repository="https://github.com/KorAP/..."
+
+# docker build -f Dockerfile -t korap/kalamar-plugin-externalresources .
+# docker run --rm --network host -v ${PWD}/db/:/db/:z -v ${PWD}/.env:/.env korap/kalamar-plugin-externalresources
\ No newline at end of file
diff --git a/README.md b/README.md
index f33a4fe..fcb30f1 100644
--- a/README.md
+++ b/README.md
@@ -57,6 +57,30 @@
- `KORAP_EXTERNAL_RESOURCES_PORT`: The port the service should be listen to.
- `KORAP_EXTERNAL_RESOURCES`: The exposed URL the service is hosted.
+## Dockerization
+
+Currently no official Docker image is provided.
+To build an image based on the provided Dockerfile, run
+
+```shell
+$ docker build \
+ -f Dockerfile \
+ -t korap/kalamar-plugin-externalresources .
+```
+
+To create a container based on the image
+with a mounted database in `db`
+and a configuration file, on Linux run
+
+```shell
+$ docker run \
+ --rm \
+ --network host \
+ -v ${PWD}/db/:/db/:z \
+ -v ${PWD}/.env:/.env korap/ \
+ kalamar-plugin-externalresources
+```
+
## License
Copyright (c) 2023, [IDS Mannheim](https://www.ids-mannheim.de/), Germany<br>
@@ -67,5 +91,5 @@
at the Leibniz Institute for the German Language
([IDS](https://www.ids-mannheim.de/)).
-Kalamar-Plugin-Resources is published under the
+Kalamar-Plugin-ExternalResources is published under the
[BSD-2 License](https://raw.githubusercontent.com/KorAP/Kalamar-Plugin-ExternalResources/master/LICENSE).