Created
December 28, 2023 15:09
-
-
Save h4ck4life/80b7bd6ea371330ecaae8c78ef2c7dd1 to your computer and use it in GitHub Desktop.
golang + sqlite3 dockerfile
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
FROM golang:alpine3.18 AS build | |
# Important: | |
# Because this is a CGO enabled package, you are required to set it as 1. | |
ENV CGO_ENABLED=1 | |
RUN apk add --no-cache \ | |
# Important: required for go-sqlite3 | |
gcc \ | |
# Required for Alpine | |
musl-dev | |
WORKDIR /workspace | |
COPY . /workspace/ | |
RUN \ | |
go mod tidy && \ | |
go install -ldflags='-s -w -extldflags "-static"' ./main.go | |
FROM scratch | |
COPY --from=build /go/bin/main /usr/local/bin/main | |
ENV PORT=8080 | |
WORKDIR /app | |
ENTRYPOINT [ "/usr/local/bin/main" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use for Chi framework: