Files
m8sh/Dockerfile
T

87 lines
2.4 KiB
Docker
Raw Normal View History

2025-11-02 10:42:25 +01:00
# syntax=docker/dockerfile:1
2026-03-29 12:24:30 +02:00
# Build frontend on the native platform to avoid QEMU-related issues with nodejs ecosystem
FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.26-alpine3.23 AS frontend-build
RUN apk --no-cache add build-base git nodejs pnpm
WORKDIR /src
2026-05-08 06:17:20 +02:00
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
RUN --mount=type=cache,target=/root/.local/share/pnpm/store pnpm install --frozen-lockfile
COPY --exclude=.git/ . .
RUN make frontend
# Build backend for each target platform
FROM docker.io/library/golang:1.26-alpine3.23 AS build-env
2018-03-12 10:59:13 +01:00
ARG GITEA_VERSION
ARG TAGS=""
ENV TAGS="bindata timetzdata $TAGS"
ARG CGO_EXTRA_CFLAGS
2018-03-12 10:59:13 +01:00
2023-10-29 02:44:06 +01:00
# Build deps
RUN apk --no-cache add \
build-base \
git
2018-03-12 10:59:13 +01:00
WORKDIR ${GOPATH}/src/gitea.dev
COPY go.mod go.sum ./
RUN go mod download
# Use COPY instead of bind mount as read-only one breaks makefile state tracking and read-write one needs binary to be moved as it's discarded.
# ".git" directory is mounted separately later only for version data extraction.
2025-11-02 10:42:25 +01:00
COPY --exclude=.git/ . .
COPY --from=frontend-build /src/public/assets public/assets
2018-03-12 10:59:13 +01:00
2025-11-02 10:42:25 +01:00
# Build gitea, .git mount is required for version data
RUN --mount=type=cache,target="/root/.cache/go-build" \
2025-11-02 10:42:25 +01:00
--mount=type=bind,source=".git/",target=".git/" \
make backend
2018-03-12 10:59:13 +01:00
2023-10-29 02:44:06 +01:00
COPY docker/root /tmp/local
2025-11-02 10:42:25 +01:00
# Set permissions for builds that made under windows which strips the executable bit from file
2023-10-29 02:44:06 +01:00
RUN chmod 755 /tmp/local/usr/bin/entrypoint \
/tmp/local/usr/local/bin/* \
2023-10-29 02:44:06 +01:00
/tmp/local/etc/s6/gitea/* \
/tmp/local/etc/s6/openssh/* \
/tmp/local/etc/s6/.s6-svscan/* \
/go/src/gitea.dev/gitea
2023-10-29 02:44:06 +01:00
FROM docker.io/library/alpine:3.23 AS gitea
2015-08-17 15:17:18 +08:00
2015-08-17 03:10:23 -04:00
EXPOSE 22 3000
2016-11-28 14:13:18 +01:00
2017-05-08 13:09:20 +02:00
RUN apk --no-cache add \
2016-11-28 14:13:18 +01:00
bash \
2018-03-12 10:59:13 +01:00
ca-certificates \
curl \
gettext \
2016-11-28 14:13:18 +01:00
git \
linux-pam \
openssh \
2018-03-12 10:59:13 +01:00
s6 \
sqlite \
su-exec \
2025-11-02 10:42:25 +01:00
gnupg
2018-03-12 10:59:13 +01:00
2017-06-30 14:10:37 +08:00
RUN addgroup \
-S -g 1000 \
2016-11-28 14:13:18 +01:00
git && \
2016-11-28 17:22:22 +01:00
adduser \
-S -H -D \
-h /data/git \
2016-11-28 14:13:18 +01:00
-s /bin/bash \
-u 1000 \
2016-11-28 17:22:22 +01:00
-G git \
2016-12-15 10:16:55 +01:00
git && \
echo "git:*" | chpasswd -e
2016-11-28 14:13:18 +01:00
2025-11-02 10:42:25 +01:00
COPY --from=build-env /tmp/local /
COPY --from=build-env /go/src/gitea.dev/gitea /app/gitea/gitea
2025-11-02 10:42:25 +01:00
ENV USER=git
ENV GITEA_CUSTOM=/data/gitea
2016-11-28 14:13:18 +01:00
VOLUME ["/data"]
# HINT: HEALTH-CHECK-ENDPOINT: don't use HEALTHCHECK, search this hint keyword for more information
2016-11-28 14:13:18 +01:00
ENTRYPOINT ["/usr/bin/entrypoint"]
2024-12-22 20:31:53 +02:00
CMD ["/usr/bin/s6-svscan", "/etc/s6"]