code.gitea.io/gitea@v1.22.3/Dockerfile.rootless (about)

     1  # Build stage
     2  FROM docker.io/library/golang:1.22-alpine3.20 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/rootless /tmp/local
    33  
    34  # Set permissions
    35  RUN chmod 755 /tmp/local/usr/local/bin/docker-entrypoint.sh \
    36                /tmp/local/usr/local/bin/docker-setup.sh \
    37                /tmp/local/usr/local/bin/gitea \
    38                /go/src/code.gitea.io/gitea/gitea \
    39                /go/src/code.gitea.io/gitea/environment-to-ini
    40  RUN chmod 644 /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete
    41  
    42  FROM docker.io/library/alpine:3.20
    43  LABEL maintainer="maintainers@gitea.io"
    44  
    45  EXPOSE 2222 3000
    46  
    47  RUN apk --no-cache add \
    48      bash \
    49      ca-certificates \
    50      dumb-init \
    51      gettext \
    52      git \
    53      curl \
    54      gnupg \
    55      && rm -rf /var/cache/apk/*
    56  
    57  RUN addgroup \
    58      -S -g 1000 \
    59      git && \
    60    adduser \
    61      -S -H -D \
    62      -h /var/lib/gitea/git \
    63      -s /bin/bash \
    64      -u 1000 \
    65      -G git \
    66      git
    67  
    68  RUN mkdir -p /var/lib/gitea /etc/gitea
    69  RUN chown git:git /var/lib/gitea /etc/gitea
    70  
    71  COPY --from=build-env /tmp/local /
    72  COPY --from=build-env --chown=root:root /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea
    73  COPY --from=build-env --chown=root:root /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini
    74  COPY --from=build-env /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete /etc/profile.d/gitea_bash_autocomplete.sh
    75  
    76  # git:git
    77  USER 1000:1000
    78  ENV GITEA_WORK_DIR=/var/lib/gitea
    79  ENV GITEA_CUSTOM=/var/lib/gitea/custom
    80  ENV GITEA_TEMP=/tmp/gitea
    81  ENV TMPDIR=/tmp/gitea
    82  
    83  # TODO add to docs the ability to define the ini to load (useful to test and revert a config)
    84  ENV GITEA_APP_INI=/etc/gitea/app.ini
    85  ENV HOME="/var/lib/gitea/git"
    86  VOLUME ["/var/lib/gitea", "/etc/gitea"]
    87  WORKDIR /var/lib/gitea
    88  
    89  ENTRYPOINT ["/usr/bin/dumb-init", "--", "/usr/local/bin/docker-entrypoint.sh"]
    90  CMD []