build: add docker setup
This commit is contained in:
20
Dockerfile
Normal file
20
Dockerfile
Normal file
@@ -0,0 +1,20 @@
|
||||
FROM golang:1.25.3-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
|
||||
# Build
|
||||
RUN go mod download
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -a -o main ./cmd/server
|
||||
###########
|
||||
|
||||
FROM alpine:3.22.2
|
||||
|
||||
RUN apk --no-cache add ca-certificates
|
||||
WORKDIR /root/
|
||||
|
||||
# Copy the pre-built binary
|
||||
COPY --from=builder /app/main .
|
||||
|
||||
EXPOSE 8080
|
||||
CMD ["./main"]
|
||||
23
docker-compose.yml
Normal file
23
docker-compose.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
services:
|
||||
go-app:
|
||||
build: .
|
||||
container_name: agenda-web-go
|
||||
environment:
|
||||
- DB_NAME=${DB_NAME}
|
||||
- DB_USER=${DB_USER}
|
||||
- DB_PASSWORD=${DB_PASSWORD}
|
||||
- DB_HOST=${DB_HOST}
|
||||
- DB_PORT=${DB_PORT}
|
||||
- ALLOWED_ORIGIN=${ALLOWED_ORIGIN}
|
||||
networks:
|
||||
- db-network
|
||||
volumes:
|
||||
#- ./cache:/root/.cache
|
||||
- ./:/app
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- 3005:8080
|
||||
|
||||
networks:
|
||||
db-network:
|
||||
external: true
|
||||
Reference in New Issue
Block a user