-
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.
- Loading branch information
Showing
9 changed files
with
113 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,25 @@ | ||
FROM golang:1.21-alpine | ||
FROM golang:1.20-alpine as base | ||
|
||
RUN apk add --no-cache make | ||
|
||
WORKDIR /app | ||
|
||
COPY go.mod go.sum ./ | ||
|
||
RUN go mod download | ||
|
||
COPY . . | ||
|
||
FROM base as dev | ||
RUN make build | ||
EXPOSE ${PORT} | ||
CMD [ "sh", "-c", "echo 'y' | make watch" ] | ||
|
||
FROM base as build | ||
RUN go build -o main cmd/api/main.go | ||
|
||
FROM alpine:3.19.0 as prod | ||
WORKDIR /app | ||
COPY --from=build /app/main /app/main | ||
COPY cmd/web cmd/web | ||
EXPOSE ${PORT} | ||
|
||
CMD ["./main"] |
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
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
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,7 +1,28 @@ | ||
version: '3.8' | ||
|
||
services: | ||
web: | ||
build: . | ||
web-dev: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
target: dev | ||
ports: | ||
- ${PORT}:${PORT} | ||
- ${PORT}:${PORT} | ||
environment: | ||
- PORT=${PORT} | ||
volumes: | ||
- ./:/app | ||
|
||
web-prod: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
target: prod | ||
ports: | ||
- ${PORT}:${PORT} | ||
environment: | ||
- PORT=${PORT} | ||
|
||
# docker-compose up --scale web-dev=0 --scale web-prod=1 --build | ||
# docker-compose up web-prod --build | ||
# docker-compose up web-dev --build |