1️⃣ STEP 1: Containerize Application

-  Image Size: ~10MB
- Created Dockerfile [Multi-stage, Scrath]
- Create docker-compose file for ease of use [cmd: docker-compose up -d]
This commit is contained in:
Jagrit Thapar 2024-09-06 18:07:31 +05:30
parent cd59e03bae
commit 974029a3db
2 changed files with 35 additions and 0 deletions

22
Dockerfile Normal file
View File

@ -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"]

13
docker-compose.yaml Normal file
View File

@ -0,0 +1,13 @@
version: '3.8'
services:
go-app:
build:
context: .
dockerfile: Dockerfile
ports:
- "8080:8080"
volumes:
- ./static:/app/static
# environment:
# - ENV=production