可以参考官方的镜像自己制作,制作准备两个文件
Dockerfile
FROM alpine as omnibus-gitlab
ARG VERSION=15.11.10
#RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
RUN apk update && apk add --update --no-cache curl git wget
RUN git clone -b ${VERSION}+ce.0 https://gitlab.com/gitlab-org/omnibus-gitlab.git /omnibus-gitlab
FROM ubuntu:22.04
ARG DEBIAN_FRONTEND=noninteractive
SHELL ["/bin/bash", "-c"]
# Install required packages
RUN apt-get update -q \
&& apt-get install -yq --no-install-recommends \
apt-transport-https\
curl\
xz-utils\
git \
busybox \
ca-certificates \
openssh-server \
tzdata \
wget \
perl \
libperl5.34 \
libatomic1 \
bash \
&& rm -rf /var/lib/apt/lists/*
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get install -y --no-install-recommends tzdata && \
dpkg-reconfigure --frontend noninteractive tzdata
# Default to supporting utf-8
ENV LANG=en_US.UTF-8
# Use BusyBox
ENV EDITOR /bin/vi
RUN busybox --install \
&& { \
echo '#!/bin/sh'; \
echo '/bin/vi "$@"'; \
} > /usr/local/bin/busybox-editor \
&& chmod +x /usr/local/bin/busybox-editor \
&& update-alternatives --install /usr/bin/editor editor /usr/local/bin/busybox-editor 1
# Remove MOTD
RUN rm -rf /etc/update-motd.d /etc/motd /etc/motd.dynamic
RUN ln -fs /dev/null /run/motd.dynamic
# Legacy code to be removed on 17.0. See: https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/7035
ENV GITLAB_ALLOW_SHA1_RSA=false
ARG VERSION=15.11.10
RUN set -eux \
; OS="$(uname | tr '[:upper:]' '[:lower:]')" \
; ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')" \
; echo "DOWNLOAD_URL=https://packages.gitlab.com/gitlab/gitlab-ce/packages/ubuntu/jammy/gitlab-ce_${VERSION}-ce.0_${ARCH}.deb/download.deb" > /RELEASE
COPY --from=omnibus-gitlab /omnibus-gitlab/docker/assets/ /assets/
# as gitlab-ci checks out with mode 666 we need to set permissions of the files we copied into the
# container to a secure value. Issue #5956
RUN chmod -R og-w /assets RELEASE ; \
/assets/setup
# Allow to access embedded tools
ENV PATH /opt/gitlab/embedded/bin:/opt/gitlab/bin:/assets:$PATH
# Resolve error: TERM environment variable not set.
ENV TERM xterm
# Expose web & ssh
EXPOSE 443 80 22
# Define data volumes
VOLUME ["/etc/gitlab", "/var/opt/gitlab", "/var/log/gitlab"]
# Wrapper to handle signal, trigger runit and reconfigure GitLab
CMD ["/assets/wrapper"]
HEALTHCHECK --interval=60s --timeout=30s --retries=5 \
CMD /opt/gitlab/bin/gitlab-healthcheck --fail --max-time 10
由于跨平台构建采用buildx bake,所以需要准备一个bake配置文件,如下:
docker-bake.hcl
variable "VERSION" {
default = "16.7.2"
}
variable "FIXID" {
default = "1"
}
group "default" {
targets = ["gitlab-ce"]
}
target "gitlab-ce" {
labels = {
"cloud.opsbox.author" = "seanly"
"cloud.opsbox.image.name" = "gitlab-ce"
"cloud.opsbox.image.version" = "${VERSION}"
"cloud.opsbox.image.fixid" = "${FIXID}"
}
dockerfile = "Dockerfile"
context = "./"
args = {
VERSION="${VERSION}"
}
platforms = ["linux/amd64", "linux/arm64"]
tags = ["seanly/appset:gitlab-ce-${VERSION}-${FIXID}"]
output = ["type=image,push=true"]
}
只需要执行
docker buildx bake -f docker-bake.hcl
下面是通过docker-compose的方式运行,也是需要准备编排文件
docker-compose.yml
version: '3'
services:
gitlab-ce:
build:
context: .
dockerfile: Dockerfile
args:
- VERSION=16.7.2
container_name: gitlab-ce
restart: always
image: seanly/appset:gitlab-ce-16.7.2
ports:
- "30022:22"
- "8080:80"
environment:
TZ: 'Asia/Shanghai'
volumes:
- ./config:/etc/gitlab
- gitlab-data:/var/opt/gitlab
volumes:
gitlab-data:
networks:
default:
name: opsbox-network
external: true
构建跨平台镜像可以通过buildkit制作
seanly/appset:gitlab-ce-16.7.2 这个是制作好的, |