-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
33 lines (26 loc) · 872 Bytes
/
Copy pathDockerfile
File metadata and controls
33 lines (26 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Build stage
FROM golang:1.21-alpine AS builder
WORKDIR /app
COPY . .
RUN go mod download
RUN CGO_ENABLED=0 GOOS=linux go build -o admin-api ./cmd/api
# Final stage
FROM alpine:latest
RUN apk add --no-cache netcat-openbsd curl
WORKDIR /app
# Create config directory first
RUN mkdir -p /app/config
# Copy files
COPY --from=builder /app/admin-api .
COPY --from=builder /app/migrations ./migrations
COPY --from=builder /app/config/config.yml /app/config/config.yml
# Make the binary executable
RUN chmod +x /app/admin-api
# Set environment variable to specify config file
ENV CONFIG_FILE=/app/config/config.yml
# Install migrate tool
RUN curl -L https://github.com/golang-migrate/migrate/releases/download/v4.16.2/migrate.linux-arm64.tar.gz | tar xvz && \
mv migrate /usr/local/bin/migrate && \
chmod +x /usr/local/bin/migrate
EXPOSE 8080
CMD ["./admin-api"]