fork from prologic/pages-server

This commit is contained in:
“xHuPo” 2024-09-14 12:00:17 +08:00
parent 9d86fd33c6
commit 839a429820
33 changed files with 865 additions and 2482 deletions

View file

@ -1,9 +1,57 @@
FROM docker.io/library/caddy:2.8-builder-alpine as builder
RUN mkdir -p /usr/local/src
COPY go.mod go.sum caddyfile.go /usr/local/src/
COPY pages /usr/local/src/pages
WORKDIR /usr/local/src
RUN ls && xcaddy build \
--with github.com/d7z-project/caddy-gitea-pages=./
FROM docker.io/library/caddy:2.8
COPY --from=builder /usr/local/src/caddy /usr/bin/caddy
# Build
FROM golang:alpine AS build
RUN apk add --no-cache -U build-base git make
RUN mkdir -p /src
WORKDIR /src
# Copy Makefile
COPY Makefile ./
# Install deps
RUN make deps
# Copy go.mod and go.sum and install and cache dependencies
COPY go.mod .
COPY go.sum .
# Copy sources
COPY *.go ./
COPY ./gitea/*.go ./gitea/
# Version/Commit (there there is no .git in Docker build context)
# NOTE: This is fairly low down in the Dockerfile instructions so
# we don't break the Docker build cache just be changing
# unrelated files that actually haven't changed but caused the
# COMMIT value to change.
ARG VERSION="0.0.0"
ARG COMMIT="HEAD"
ARG BUILD=""
# Build server binary
RUN make server VERSION=$VERSION COMMIT=$COMMIT BUILD=$BUILD
# Runtime
FROM alpine:latest
RUN apk --no-cache -U add ca-certificates tzdata
ENV PUID=1000
ENV PGID=1000
RUN mkdir -p /data && chown -R nobody:nobody /data
EXPOSE 8000/tcp
VOLUME /data
WORKDIR /
# force cgo resolver
ENV GODEBUG=netdns=cgo
COPY --from=build /src/pages-server /usr/local/bin/pages-server
CMD ["pages-server"]