Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions cmd/server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
FROM golang:1.14-alpine AS build

RUN mkdir -p /go/src/github.com/zacscoding/gin-rest-api-example ~/.ssh && \
apk add --no-cache git openssh-client make gcc libc-dev
WORKDIR /go/src/github.com/zacscoding/gin-rest-api-example
FROM golang:1.21-alpine AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN make build
RUN CGO_ENABLED=0 GOOS=linux go build -o article-server ./cmd/server
FROM alpine:latest

RUN apk --no-cache add ca-certificates tzdata

WORKDIR /app
COPY --from=builder /app/article-server .
COPY --from=builder /app/config ./config
COPY --from=builder /app/migrations ./migrations

EXPOSE 8080

FROM alpine:3
COPY --from=build /go/src/github.com/zacscoding/gin-rest-api-example/article-server /bin/article-server
CMD /bin/article-server
CMD ["./article-server"]
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ services:
volumes:
- ./config/local.yaml:/config/config.yaml
- ./migrations:/config/migrations
command: article-server --conf /config/config.yaml
command: ./article-server --conf /config/config.yaml
restart: always
depends_on:
- "db"
Expand Down