From bb0cb6e2695711e3c6bb8df221e2bd95e5f27c85 Mon Sep 17 00:00:00 2001 From: Saumit Dinesan Date: Mon, 25 Dec 2023 00:17:20 +0530 Subject: Dockerfile & README.md: Containerizing the API and completing the TODO, adding TODO for Docker Image size optimization --- Dockerfile | 21 +++++++++++++++++++++ README.md | 3 ++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..41a64e1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +#FROM golang:1.21.5-bullseye - debian/ubuntu has build dependencies(gcc) +FROM golang:1.21.5-alpine + +RUN mkdir /app + +ADD . /app + +WORKDIR /app + +#Install the build dependencies +RUN apk add --no-cache gcc libc-dev + +#CGO_ENABLED=1 for go-sqlite3 to work +RUN CGO_ENABLED=1 go build -o main . + +# Volume for SSL/TLS Certificates(optional for development) +VOLUME /certs + +EXPOSE 3000 + +CMD ["/app/main"] diff --git a/README.md b/README.md index df22c95..4ded777 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,8 @@ Once the server is running, you can access the API endpoints to upload a file fo - [x] Connect with DB - [x] Store JSON data to DB - [x] Perform verification -- [ ] Containerize the API +- [x] Containerize the API +- [ ] Optimize Docker Image size (Currently 509MB) ## License This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. -- cgit v1.2.3