-
Notifications
You must be signed in to change notification settings - Fork 1
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
12 changed files
with
1,293 additions
and
383 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,27 +1,44 @@ | ||
FROM golang:1.22 AS build | ||
FROM golang:1-alpine AS builder | ||
|
||
RUN apk add --no-cache build-base | ||
|
||
ENV USER=appuser | ||
ENV UID=10001 | ||
RUN adduser \ | ||
--disabled-password \ | ||
--gecos "" \ | ||
--home "/nonexistent" \ | ||
--shell "/sbin/nologin" \ | ||
--no-create-home \ | ||
--uid "${UID}" \ | ||
"${USER}" | ||
|
||
WORKDIR /build | ||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
|
||
COPY . ./ | ||
|
||
ENV GOFLAGS='-tags="sqlite_json"' | ||
ENV CGO_ENABLED=1 | ||
ENV GOOS=linux | ||
RUN go build -o xtemplate ./cmd | ||
COPY . . | ||
RUN CGO_ENABLED=1 \ | ||
GOFLAGS='-tags="sqlite_json"' \ | ||
GOOS=linux \ | ||
GOARCH=amd64 \ | ||
go build -ldflags="-w -s" -o /dist/xtemplate ./cmd | ||
RUN ldd /dist/xtemplate | tr -s [:blank:] '\n' | grep ^/ | xargs -I % install -D % /dist/% | ||
RUN ln -s ld-musl-x86_64.so.1 /dist/lib/libc.musl-x86_64.so.1 | ||
|
||
### | ||
|
||
FROM scratch | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=build /build/xtemplate /app/xtemplate | ||
COPY --from=builder /etc/passwd /etc/group /etc/ | ||
COPY --from=builder /dist/lib /lib/ | ||
COPY --from=builder /dist/xtemplate /app/xtemplate | ||
|
||
WORKDIR /app | ||
VOLUME /app/data | ||
USER appuser:appuser | ||
EXPOSE 80 | ||
|
||
ENTRYPOINT ["/app/xtemplate"] | ||
|
||
CMD ["-template-root", "/app/templates", "-watch-template", "false", "-log", "0"] | ||
CMD ["-template-path", "/app/templates", "-watch-template", "false", "-log", "0", "-listen", ":80"] |
Oops, something went wrong.