Skip to content

Commit

Permalink
improve dockerfile, add apprunner config
Browse files Browse the repository at this point in the history
  • Loading branch information
kubegu committed Oct 12, 2024
1 parent 0e6e1c8 commit ad1c0df
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
18 changes: 9 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Stage Build
FROM golang:1.20 as build
FROM golang:1.23 as build

ENV GOOS=linux
ENV GOARCH=amd64
Expand All @@ -8,14 +8,14 @@ ENV CGO_ENABLED=0
WORKDIR /app

COPY . ./

RUN go mod download
RUN go build -o web

RUN make build-web

# Stage Run
FROM alpine:latest
WORKDIR /app
COPY --from=build /app/web .
RUN chmod +x web
CMD ["./web"]
EXPOSE 8080
FROM gcr.io/distroless/base-debian11
WORKDIR /
COPY --from=build /app/bin/web /web
EXPOSE 8080
USER nonroot:nonroot
ENTRYPOINT ["/web"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ build-cli:
go build ./...
go build -o bin/cli cmd/cli/main.go

docker:
docker-build:
docker build -t gunni1/lib-api:local .

docker-run:
Expand Down
10 changes: 10 additions & 0 deletions apprunner.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 1.0
runtime: go1
build:
commands:
build:
- go build -o bin/web main.go
run:
command: ./bin/web
network:
port: 8080

0 comments on commit ad1c0df

Please sign in to comment.