File tree Expand file tree Collapse file tree 7 files changed +107
-56
lines changed
Expand file tree Collapse file tree 7 files changed +107
-56
lines changed Original file line number Diff line number Diff line change 1+ # .dockerignore
2+ .git
3+ build
4+ bin
5+ dist
6+ .github
7+ Dockerfile
8+ docker-compose.yml
9+ * .md
Original file line number Diff line number Diff line change 1+ version : " 3.8"
2+
3+ services :
4+ reverse-proxy :
5+ image : traefik:v3.4
6+ command :
7+ - " --providers.docker"
8+ - " --providers.docker.exposedbydefault=false"
9+ - " --entryPoints.web.address=:80"
10+ - " --entryPoints.websecure.address=:443"
11+ - " --certificatesresolvers.myresolver.acme.tlschallenge=true"
12+ - " --certificatesresolvers.myresolver.acme.email=ongchen10sherpa@gmail.com"
13+ - " --certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
14+ - " --entrypoints.web.http.redirections.entrypoint.to=websecure"
15+ - " --entrypoints.web.http.redirections.entrypoint.scheme=https"
16+ - " --api.dashboard=true"
17+ ports :
18+ - " 80:80"
19+ - " 443:443"
20+ - " 8080:8080"
21+ labels :
22+ - " traefik.enable=true"
23+ - " traefik.http.routers.traefik.rule=Host(`traefik.gocloudnepal.com`)"
24+ - " traefik.http.routers.traefik.entrypoints=websecure"
25+ - " traefik.http.routers.traefik.tls.certresolver=myresolver"
26+ - " traefik.http.services.traefik.loadbalancer.server.port=8080"
27+ volumes :
28+ - letsencrypt:/letsencrypt
29+ - /var/run/docker.sock:/var/run/docker.sock
30+
31+ khel :
32+ image : khel
33+ build :
34+ context : .
35+ dockerfile : Dockerfile
36+ labels :
37+ - " traefik.enable=true"
38+ - " traefik.http.routers.khel.rule=Host(`gocloudnepal.com`)"
39+ - " traefik.http.routers.khel.entrypoints=websecure"
40+ - " traefik.http.routers.khel.tls.certresolver=myresolver"
41+ env_file :
42+ - .env
43+ restart : always
44+
45+ watchtower :
46+ image : containrrr/watchtower
47+ command :
48+ - " --label-enable"
49+ - " --interval=30"
50+ - " --rolling-restart"
51+ volumes :
52+ - /var/run/docker.sock:/var/run/docker.sock
53+
54+ volumes :
55+ letsencrypt :
Original file line number Diff line number Diff line change 1+ # Stage 1: Install dependencies
2+ FROM golang:1.24-bookworm AS deps
3+
4+ WORKDIR /app
5+
6+ COPY go.mod go.sum ./
7+
8+ RUN go mod download
9+
10+ # Stage 2: Build the application
11+ FROM golang:1.24-bookworm AS builder
12+
13+ WORKDIR /app
14+
15+ COPY --from=deps /go/pkg /go/pkg
16+ COPY . .
17+ COPY .env .
18+
19+
20+ ENV CGO_ENABLED=0
21+ ENV GOOS=linux
22+
23+ # Output binary as main
24+ RUN go build -ldflags="-w -s" -o main ./cmd/api
25+
26+ # Final stage: Run the application
27+ FROM debian:bookworm-slim
28+
29+ WORKDIR /app
30+
31+ # Create a non-root user and group
32+ RUN groupadd -r appuser && useradd -r -g appuser appuser
33+
34+ # Copy the built application
35+ COPY --from=builder /app/main .
36+
37+ # Change ownership of the application binary
38+ RUN chown appuser:appuser /app/main
39+
40+ # Switch to the non-root user
41+ USER appuser
42+
43+ CMD ["./main"]
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments