Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
infogulch committed Mar 22, 2024
1 parent b9b37fe commit 9fa77cc
Show file tree
Hide file tree
Showing 12 changed files with 1,293 additions and 383 deletions.
39 changes: 28 additions & 11 deletions Dockerfile
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"]
Loading

0 comments on commit 9fa77cc

Please sign in to comment.