1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
|
ARG GDK_SHA=4d74dc68619bb2f81fb22216fa9ca5d3b15b67bc
# Use tag prefix when running on 'stable' branch to make sure 'protected' image is used which is not deleted by registry cleanup
ARG GDK_BASE_TAG_PREFIX
FROM registry.gitlab.com/gitlab-org/gitlab-development-kit/asdf-bootstrapped-verify/main:${GDK_BASE_TAG_PREFIX}${GDK_SHA} AS base
ENV GITLAB_LICENSE_MODE=test \
GDK_KILL_CONFIRM=true
# Clone GDK at specific sha and bootstrap packages
#
ARG GDK_SHA
RUN set -eux; \
git clone --depth 1 https://gitlab.com/gitlab-org/gitlab-development-kit.git && cd gitlab-development-kit; \
git fetch --depth 1 origin ${GDK_SHA} && git -c advice.detachedHead=false checkout ${GDK_SHA}; \
mkdir gitlab \
&& make bootstrap \
&& sudo apt-get autoclean
WORKDIR /home/gdk/gitlab-development-kit
COPY --chown=gdk:gdk qa/gdk/gdk.yml ./
# Build gitlab-shell
#
FROM base AS gitlab-shell
COPY --chown=gdk:gdk GITLAB_SHELL_VERSION ./gitlab/
RUN make gitlab-shell-setup \
&& cd gitlab-shell \
&& go clean -cache -modcache -r \
&& rm -rf /home/gdk/.asdf/installs/ruby/*/lib/ruby/gems/*/cache
# Build gitlab-workhorse
#
FROM base AS workhorse
COPY --chown=gdk:gdk VERSION GITLAB_WORKHORSE_VERSION ./gitlab/
COPY --chown=gdk:gdk workhorse ./gitlab/workhorse
RUN make gitlab-workhorse-setup \
&& cd gitlab/workhorse \
&& go clean -cache -modcache -r
# Build gitaly
#
FROM base AS gitaly
COPY --chown=gdk:gdk GITALY_SERVER_VERSION ./gitlab/
RUN set -eux; \
make gitaly-setup; \
cd gitaly \
&& go clean -cache -modcache -r \
&& rm -rf _build/cache \
_build/deps \
_build/intermediate
# Install gitlab gem dependencies
#
FROM base AS gitlab-gems
COPY --chown=gdk:gdk Gemfile Gemfile.lock .tool-versions ./gitlab/
COPY --chown=gdk:gdk vendor/gems/ ./gitlab/vendor/gems/
COPY --chown=gdk:gdk gems/ ./gitlab/gems/
RUN make gitlab-asdf-install \
&& make .gitlab-bundle \
&& cd gitlab \
&& rm -rf /home/gdk/.asdf/installs/ruby/*/lib/ruby/gems/*/cache
# Install gitlab npm dependencies
#
FROM base AS gitlab-node-modules
COPY --chown=gdk:gdk package.json yarn.lock ./gitlab/
COPY --chown=gdk:gdk scripts/frontend/postinstall.js ./gitlab/scripts/frontend/postinstall.js
COPY --chown=gdk:gdk scripts/frontend/preinstall.mjs ./gitlab/scripts/frontend/preinstall.mjs
RUN make .gitlab-yarn && yarn cache clean
# Build final image
#
FROM base AS gdk
# Set global defaults so we can initialize empty git repo
RUN git config --global init.defaultBranch master \
&& git config --global user.email "gdk@example.com" \
&& git config --global user.name "gdk"
# Copy all components from separate docker stages
COPY --from=gitlab-shell --chown=gdk:gdk /home/gdk/gitlab-development-kit/gitlab-shell ./gitlab-shell/
COPY --from=gitaly --chown=gdk:gdk /home/gdk/gitlab-development-kit/gitaly ./gitaly/
COPY --from=workhorse --chown=gdk:gdk /home/gdk/gitlab-development-kit/gitlab/workhorse ./gitlab/workhorse/
COPY --from=gitlab-gems --chown=gdk:gdk /home/gdk/.asdf/installs/ruby /home/gdk/.asdf/installs/ruby/
COPY --from=gitlab-node-modules --chown=gdk:gdk /home/gdk/gitlab-development-kit/gitlab/node_modules ./gitlab/node_modules/
# Copy code
COPY --chown=gdk:gdk ./ ./gitlab/
COPY --chown=gdk:gdk qa/gdk/entrypoint ../
# Create custom hook for E2E tests
RUN mkdir -p /home/gdk/gitlab-development-kit/gitaly-custom-hooks/pre-receive.d
COPY --chown=gdk:gdk --chmod=700 qa/gdk/pre-receive /home/gdk/gitlab-development-kit/gitaly-custom-hooks/pre-receive.d
# Set up GDK
RUN set -eux; \
# We need to init git repository within docker build because external .git folder
# will always invalidate cache on 'COPY --chown=gdk:gdk ./ ./gitlab/' step and some gdk setup steps require gitlab
# to be an actual git repository
(cd gitlab && git init . && git add --all && git commit --quiet -m "Init repository") &> /dev/null; \
gdk config set gitaly.skip_setup true \
&& gdk config set workhorse.skip_setup true \
&& gdk config set gitlab_shell.skip_setup true \
&& cp .ruby-version ./gitlab/ \
&& cp .tool-versions ./gitlab/ \
&& make redis/redis.conf all \
&& gdk kill
ENTRYPOINT [ "/home/gdk/entrypoint" ]
CMD [ "gdk", "tail" ]
HEALTHCHECK --interval=10s --timeout=1s --start-period=5s --retries=17 \
CMD curl --fail http://gdk.test:3000/users/sign_in || exit 1
EXPOSE 3000
|