2019-01-04 17:05:39 +00:00
|
|
|
################################################################################
|
|
|
|
## GO BUILDER
|
|
|
|
################################################################################
|
2024-06-10 16:52:01 +00:00
|
|
|
FROM golang:1.22.4 as builder
|
2018-07-15 07:09:51 +00:00
|
|
|
|
2024-06-10 16:56:06 +00:00
|
|
|
ENV VERSION 1.8.11
|
2022-03-09 16:46:44 +00:00
|
|
|
ENV CGO_ENABLED 0
|
2018-12-20 21:37:17 +00:00
|
|
|
ENV BUILD_DIR /build
|
|
|
|
|
|
|
|
RUN mkdir -p ${BUILD_DIR}
|
|
|
|
WORKDIR ${BUILD_DIR}
|
|
|
|
|
|
|
|
COPY go.* ./
|
|
|
|
RUN go mod download
|
2018-07-15 07:09:51 +00:00
|
|
|
COPY . .
|
|
|
|
|
2018-12-20 14:59:09 +00:00
|
|
|
RUN go test -cover ./...
|
2022-11-29 18:05:33 +00:00
|
|
|
RUN go build -a -tags netgo -installsuffix netgo -ldflags "-s -w -X github.com/halverneus/static-file-server/cli/version.version=${VERSION}" -o /serve /build/bin/serve
|
2017-06-23 14:28:11 +00:00
|
|
|
|
2020-01-24 10:53:28 +00:00
|
|
|
RUN adduser --system --no-create-home --uid 1000 --shell /usr/sbin/nologin static
|
|
|
|
|
2019-01-04 17:05:39 +00:00
|
|
|
################################################################################
|
|
|
|
## DEPLOYMENT CONTAINER
|
|
|
|
################################################################################
|
2017-06-23 14:28:11 +00:00
|
|
|
FROM scratch
|
2019-01-04 17:05:39 +00:00
|
|
|
|
|
|
|
EXPOSE 8080
|
2017-06-23 14:28:11 +00:00
|
|
|
COPY --from=builder /serve /
|
2020-01-24 10:53:28 +00:00
|
|
|
COPY --from=builder /etc/passwd /etc/passwd
|
|
|
|
|
|
|
|
USER static
|
2018-11-15 00:16:03 +00:00
|
|
|
ENTRYPOINT ["/serve"]
|
|
|
|
CMD []
|
2018-12-20 23:15:27 +00:00
|
|
|
|
|
|
|
# Metadata
|
|
|
|
LABEL life.apets.vendor="Halverneus" \
|
2020-02-05 18:25:39 +00:00
|
|
|
life.apets.url="https://github.com/halverneus/static-file-server" \
|
|
|
|
life.apets.name="Static File Server" \
|
|
|
|
life.apets.description="A tiny static file server" \
|
2024-06-10 16:56:06 +00:00
|
|
|
life.apets.version="v1.8.11" \
|
2020-02-05 18:25:39 +00:00
|
|
|
life.apets.schema-version="1.0"
|