-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update dockerfile to run for dev or prod (#32)
- Loading branch information
Showing
4 changed files
with
43 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,35 @@ | ||
FROM golang:alpine | ||
FROM golang:1.23.2-alpine AS builder | ||
|
||
RUN apk update && apk add --no-cache git && apk add --no-cach bash && apk add build-base | ||
|
||
RUN mkdir /app | ||
WORKDIR /app | ||
|
||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
|
||
COPY . . | ||
|
||
RUN go install github.com/air-verse/air@latest | ||
RUN go mod download | ||
RUN go build -o bin/piccolo ./cmd/piccolo | ||
|
||
FROM golang:1.23.2-alpine AS runner | ||
|
||
WORKDIR /root/ | ||
|
||
COPY . . | ||
COPY --from=builder /app/bin/piccolo . | ||
|
||
ARG ENV=production | ||
ENV ENV=$ENV | ||
|
||
RUN if [ "$ENV" = "local" ]; then \ | ||
go mod download; \ | ||
go install github.com/air-verse/air@latest; \ | ||
else \ | ||
go build --o bin/piccolo ./cmd/piccolo; \ | ||
fi | ||
|
||
EXPOSE 8000 | ||
EXPOSE 8001 | ||
|
||
CMD [ "make", "run" ] | ||
CMD if [ "$ENV" = "local" ]; then \ | ||
air; \ | ||
else \ | ||
./piccolo; \ | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters