Ubuntun 22.04
安装 Podman4
ubuntu_version='22.04'
key_url="https://provo-mirror.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_${ubuntu_version}/Release.key"
sources_url="https://provo-mirror.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_${ubuntu_version}"
echo "deb $sources_url/ /" | tee /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list
curl -fsSL $key_url | gpg --dearmor | tee /etc/apt/trusted.gpg.d/devel_kubic_libcontainers_unstable.gpg > /dev/null
apt update
apt install podman
开机自启动
systemctl enable --now podman-restart podman.socket
容器部署
前置任务
网络部署
podman network create web
podman pod create --net web -p 80:80 -p 443:443 -p 8080:8080 nexus
部署 traefik
创建 acme.json
并正确给予权限
mkdir -p /data/traefik/config
touch /data/traefik/config/acme.json
chmod 0600 /data/traefik/config/acme.json
运行 traefik
podman run --name=traefik -d \
--replace \
--restart always \
--pod nexus \
--health-cmd="traefik healthcheck --ping" \
--health-interval=10s \
--health-timeout=3s \
--health-retries=3 \
-v /run/podman/podman.sock:/var/run/docker.sock:z \
-v /data/traefik/config/acme.json:/config/acme.json:z \
dockerproxy.com/rapidfort/traefik:v2.9.10 \
--ping \
--api.insecure=true \
--providers.docker=true \
--entrypoints.web.address=":80" \
--entrypoints.websecure.address=":443" \
--entrypoints.web.http.redirections.entryPoint.to=websecure \
--entrypoints.web.http.redirections.entryPoint.scheme=https \
--certificatesresolvers.le.acme.email=admin@admin.local \
--certificatesresolvers.le.acme.storage=/config/acme.json \
--certificatesresolvers.le.acme.tlschallenge=true
部署 portainer
创建分卷
mkdir -p /data/portainer-data
podman volume create --opt type=bind --opt device=/data/portainer-data portainer-data
部署
podman run --name=portainer -d \
--replace \
--restart always \
--pod nexus \
--health-cmd="wget --no-check-certificate -O /dev/null --no-verbose --tries=3 --spider --header='Content-Type:application/json' http://127.0.0.1:9000/api/system/status || exit 1" \
--health-interval=10s \
--health-timeout=3s \
--health-retries=3 \
-v /run/podman/podman.sock:/var/run/docker.sock:z \
-v portainer-data:/data \
-l traefik.enable=true \
-l traefik.http.routers.portainer.rule=Host\(\`portainer.nexus.juminfo.org\`\) \
-l traefik.http.routers.portainer.entrypoints=web,websecure \
-l traefik.http.services.portainer.loadbalancer.server.port=9000 \
-l traefik.http.routers.portainer.tls=true \
-l traefik.http.routers.portainer.service=portainer \
--privileged \
--expose=9000 \
dockerproxy.com/portainer/portainer-ce:linux-amd64-2.19.1-alpine \
-H unix:///var/run/docker.sock
部署核心项目
编译打包 nexus
- 这里添加 rust 的支持
git clone https://github.com/bguerin/nexus-repository-cargo.git
cd nexus-repository-cargo
cat > build.sh <<EOF
builder=$(buildah from docker.io/library/maven:3-jdk-8-alpine)
buildah copy $builder . /nexus-repository-cargo
buildah run --network=host --mount=type=cache,target=/root/.m2 $builder apk add --no-cache git
buildah run --network=host --mount=type=cache,target=/root/.m2 --workingdir /nexus-repository-cargo $builder mvn clean package -PbuildKar
nexus3=$(buildah from docker.io/sonatype/nexus3:3.61.0)
builder_path=$(buildah mount $buidler)
nexus_path=$(buildah mount $nexus3)
cp -av $builder_path/nexus-repository-cargo/target/nexus-repository-cargo-*.kar $nexus_path/opt/sonatype/nexus/deploy/
buildah umount $builder
buildah umount $nexus3
buildah commit $nexus3 docker.io/ssfdust/nexus3-cargo:3.61.0
buildah rm $nexus3
buildah rm $builder
EOF
buildah unshare bash build.sh
部署 nexus
podman run -d --name nexus-server \
--replace \
--restart=always \
--expose=8081 \
--expose=8085 \
--pod nexus \
-l traefik.enable=true \
-l traefik.http.routers.nexus.rule=Host\(\`nexus-server.juminfo.org\`\) \
-l traefik.http.routers.nexus.entrypoints=websecure \
-l traefik.http.services.nexus.loadbalancer.server.port=8081 \
-l traefik.http.routers.nexus.tls=true \
-l traefik.http.routers.nexus.service=nexus \
-l traefik.http.routers.docker.rule=Host\(\`docker-nexus.juminfo.org\`\) \
-l traefik.http.routers.docker.entrypoints=websecure \
-l traefik.http.services.docker.loadbalancer.server.port=8085 \
-l traefik.http.routers.docker.tls=true \
-l traefik.http.routers.docker.service=docker \
docker.io/ssfdust/nexus3-cargo:3.61.0
使用
Pypi
需要指定 registry
与 trusted-host
npm
指定 registry
即可使用
Docker
需要指定 insecure
dnf
需要在 /etc/yum.conf
中的 [main]
模块下添加 sslverify=false
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于