code.gitea.io/gitea@v1.21.7/Dockerfile (about)

     1  # Build stage
     2  FROM docker.io/library/golang:1.21-alpine3.18 AS build-env
     3  
     4  ARG GOPROXY
     5  ENV GOPROXY ${GOPROXY:-direct}
     6  
     7  ARG GITEA_VERSION
     8  ARG TAGS="sqlite sqlite_unlock_notify"
     9  ENV TAGS "bindata timetzdata $TAGS"
    10  ARG CGO_EXTRA_CFLAGS
    11  
    12  # Build deps
    13  RUN apk --no-cache add \
    14      build-base \
    15      git \
    16      nodejs \
    17      npm \
    18      && rm -rf /var/cache/apk/*
    19  
    20  # Setup repo
    21  COPY . ${GOPATH}/src/code.gitea.io/gitea
    22  WORKDIR ${GOPATH}/src/code.gitea.io/gitea
    23  
    24  # Checkout version if set
    25  RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \
    26   && make clean-all build
    27  
    28  # Begin env-to-ini build
    29  RUN go build contrib/environment-to-ini/environment-to-ini.go
    30  
    31  # Copy local files
    32  COPY docker/root /tmp/local
    33  
    34  # Set permissions
    35  RUN chmod 755 /tmp/local/usr/bin/entrypoint \
    36                /tmp/local/usr/local/bin/gitea \
    37                /tmp/local/etc/s6/gitea/* \
    38                /tmp/local/etc/s6/openssh/* \
    39                /tmp/local/etc/s6/.s6-svscan/* \
    40                /go/src/code.gitea.io/gitea/gitea \
    41                /go/src/code.gitea.io/gitea/environment-to-ini
    42  RUN chmod 644 /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete
    43  
    44  FROM docker.io/library/alpine:3.18
    45  LABEL maintainer="maintainers@gitea.io"
    46  
    47  EXPOSE 22 3000
    48  
    49  RUN apk --no-cache add \
    50      bash \
    51      ca-certificates \
    52      curl \
    53      gettext \
    54      git \
    55      linux-pam \
    56      openssh \
    57      s6 \
    58      sqlite \
    59      su-exec \
    60      gnupg \
    61      && rm -rf /var/cache/apk/*
    62  
    63  RUN addgroup \
    64      -S -g 1000 \
    65      git && \
    66    adduser \
    67      -S -H -D \
    68      -h /data/git \
    69      -s /bin/bash \
    70      -u 1000 \
    71      -G git \
    72      git && \
    73    echo "git:*" | chpasswd -e
    74  
    75  ENV USER git
    76  ENV GITEA_CUSTOM /data/gitea
    77  
    78  VOLUME ["/data"]
    79  
    80  ENTRYPOINT ["/usr/bin/entrypoint"]
    81  CMD ["/bin/s6-svscan", "/etc/s6"]
    82  
    83  COPY --from=build-env /tmp/local /
    84  COPY --from=build-env /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea
    85  COPY --from=build-env /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini
    86  COPY --from=build-env /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete /etc/profile.d/gitea_bash_autocomplete.sh