diff options
author | Saumit Dinesan <justsaumit@protonmail.com> | 2023-12-26 01:04:24 +0530 |
---|---|---|
committer | Saumit Dinesan <justsaumit@protonmail.com> | 2023-12-26 01:04:24 +0530 |
commit | 75a1922a02f9488f605b8c49994b28b8e764d6be (patch) | |
tree | 08d45a03a74f06961b0e7ee48de620e126126c37 /Dockerfile | |
parent | 704d51df9a371f39c3137fcf7dcfc164b3150983 (diff) |
Dockerfile & README.md: Optimizing Docker Image Size, adding persistant db using docker volume flag along w .env
Diffstat (limited to 'Dockerfile')
-rw-r--r-- | Dockerfile | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -1,18 +1,27 @@ -#FROM golang:1.21.5-bullseye - debian/ubuntu has build dependencies(gcc) -FROM golang:1.21.5-alpine +FROM golang:1.21.5-alpine AS builder RUN mkdir /app +WORKDIR /app -ADD . /app +COPY go.mod go.sum ./ +RUN go mod download -WORKDIR /app +COPY . . #Install the build dependencies RUN apk add --no-cache gcc libc-dev +# Build the binary #CGO_ENABLED=1 for go-sqlite3 to work RUN CGO_ENABLED=1 go build -o main . +# Runner Stage +FROM alpine:latest + +WORKDIR /app + +COPY --from=builder /app/main . + # Volume for SSL/TLS Certificates(optional for development) VOLUME /certs |