From 974029a3dbadecef1da343dced65bf0ebdb9573e Mon Sep 17 00:00:00 2001 From: Jagrit Thapar Date: Fri, 6 Sep 2024 18:07:31 +0530 Subject: [PATCH] =?UTF-8?q?1=EF=B8=8F=E2=83=A3=20STEP=201:=20Containerize?= =?UTF-8?q?=20Application=20-=20=E2=AD=90=20Image=20Size:=20~10MB=20-=20Cr?= =?UTF-8?q?eated=20Dockerfile=20[Multi-stage,=20Scrath]=20-=20Create=20doc?= =?UTF-8?q?ker-compose=20file=20for=20ease=20of=20use=20[cmd:=20docker-com?= =?UTF-8?q?pose=20up=20-d]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 22 ++++++++++++++++++++++ docker-compose.yaml | 13 +++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yaml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..463d880 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM golang:1.23-alpine as builder + +WORKDIR /app + +COPY go.mod . + +RUN go mod download + +COPY . . + +RUN go build -o APP + +FROM scratch + +COPY --from=builder /app/APP . + +COPY --from=builder /app/static ./static + +EXPOSE 8080 + +CMD ["./APP"] + diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..ab19af7 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,13 @@ +version: '3.8' + +services: + go-app: + build: + context: . + dockerfile: Dockerfile + ports: + - "8080:8080" + volumes: + - ./static:/app/static +# environment: +# - ENV=production \ No newline at end of file