forked from go-gitea/gitea
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify Dockerfile to create a build container
- Loading branch information
Showing
1 changed file
with
26 additions
and
56 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,70 +1,40 @@ | ||
#Build stage | ||
FROM docker.io/library/golang:1.20-alpine3.18 AS build-env | ||
FROM docker.io/library/golang:1.20-bullseye AS build-env | ||
|
||
ARG GOPROXY | ||
ENV GOPROXY ${GOPROXY:-direct} | ||
|
||
ARG GITEA_VERSION | ||
ARG TAGS="sqlite sqlite_unlock_notify" | ||
ENV TAGS "bindata timetzdata $TAGS" | ||
ARG TAGS="" | ||
ENV TAGS "bindata $TAGS" | ||
ARG CGO_EXTRA_CFLAGS | ||
|
||
#Build deps | ||
RUN apk --no-cache add build-base git nodejs npm | ||
# RUN apk --no-cache add build-base git nodejs npm | ||
RUN apt-get update | ||
RUN apt-get --yes install --no-install-recommends git ca-certificates curl gnupg && apt-get --yes clean | ||
# nodejs in bullseye is too old | ||
# Use the version from the alpine version used by Gitea in their dockerfile | ||
RUN \ | ||
mkdir -p /etc/apt/keyrings && \ | ||
(curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg) && \ | ||
(echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list) && \ | ||
apt-get update && \ | ||
apt-get --yes install --no-install-recommends nodejs && \ | ||
apt-get --yes clean | ||
|
||
#Setup repo | ||
COPY . ${GOPATH}/src/code.gitea.io/gitea | ||
WORKDIR ${GOPATH}/src/code.gitea.io/gitea | ||
# <- COPY go.mod and go.sum files | ||
RUN mkdir /deps | ||
WORKDIR /deps | ||
COPY go.mod . | ||
COPY go.sum . | ||
RUN go mod download -x | ||
|
||
#Checkout version if set | ||
RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \ | ||
&& make clean-all build | ||
COPY package-lock.json . | ||
COPY package.json . | ||
RUN npm install --global | ||
|
||
# Begin env-to-ini build | ||
RUN go build contrib/environment-to-ini/environment-to-ini.go | ||
|
||
FROM docker.io/library/alpine:3.18 | ||
LABEL maintainer="[email protected]" | ||
WORKDIR ${GOPATH}/src/gitea | ||
|
||
EXPOSE 22 3000 | ||
|
||
RUN apk --no-cache add \ | ||
bash \ | ||
ca-certificates \ | ||
curl \ | ||
gettext \ | ||
git \ | ||
linux-pam \ | ||
openssh \ | ||
s6 \ | ||
sqlite \ | ||
su-exec \ | ||
gnupg | ||
|
||
RUN addgroup \ | ||
-S -g 1000 \ | ||
git && \ | ||
adduser \ | ||
-S -H -D \ | ||
-h /data/git \ | ||
-s /bin/bash \ | ||
-u 1000 \ | ||
-G git \ | ||
git && \ | ||
echo "git:*" | chpasswd -e | ||
|
||
ENV USER git | ||
ENV GITEA_CUSTOM /data/gitea | ||
|
||
VOLUME ["/data"] | ||
|
||
ENTRYPOINT ["/usr/bin/entrypoint"] | ||
CMD ["/bin/s6-svscan", "/etc/s6"] | ||
|
||
COPY docker/root / | ||
COPY --from=build-env /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea | ||
COPY --from=build-env /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini | ||
COPY --from=build-env /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete /etc/profile.d/gitea_bash_autocomplete.sh | ||
RUN chmod 755 /usr/bin/entrypoint /app/gitea/gitea /usr/local/bin/gitea /usr/local/bin/environment-to-ini | ||
RUN chmod 755 /etc/s6/gitea/* /etc/s6/openssh/* /etc/s6/.s6-svscan/* | ||
RUN chmod 644 /etc/profile.d/gitea_bash_autocomplete.sh | ||
RUN git config --global --add safe.directory ${GOPATH}/src/gitea |