Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cdd25083f2 | |||
| 9b0aa0a306 | |||
| f1e39853f2 | |||
| 92e3df45b6 | |||
| c128fa3ca3 | |||
| 75fe9141d9 | |||
| e130909ba1 | |||
| 6bf512f997 | |||
| 7ccdb9b50b | |||
| 5109b9ab22 | |||
| dcc4093db9 | |||
| d23361a9ea |
@@ -1,12 +0,0 @@
|
||||
.git
|
||||
.gitignore
|
||||
|
||||
./alpine
|
||||
./Makefile
|
||||
|
||||
*.yml
|
||||
*.yaml
|
||||
|
||||
./LICENSE
|
||||
./README.md
|
||||
./img
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
|
||||
Icon\r\r
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
@@ -1,61 +0,0 @@
|
||||
# CI/CD 的阶段定义,按顺序执行各阶段;默认包含`.pre`(最先执行)/`.post`(最后执行)两个阶段,不用显示定义
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
- deploy
|
||||
|
||||
# 全局变量定义
|
||||
variables:
|
||||
IMG_URL: "$HARBOR_HOST/$HARBOR_PROJECT/$CI_PROJECT_NAME"
|
||||
IMG_TAG: ":latest"
|
||||
|
||||
# 默认值信息配置
|
||||
default:
|
||||
# 各 stage 使用的默认镜像,如果不定义,则为 gitlab-runner 创建时指定的镜像;各 stage 可以覆盖该值以使用不同的镜像
|
||||
image: docker.colovu.com/library/docker:20.10.16
|
||||
# Gitlab-runner 配置的执行器为 Docker 时,需要 配置对应的 dind 服务
|
||||
services:
|
||||
- name: docker.colovu.com/library/docker:20.10.16-dind
|
||||
alias: docker
|
||||
# 流水线中,各阶段都会执行的脚本命令,包括`before_script`(在各阶段 script 前执行)/`after_script`(在各阶段 script 后执行)
|
||||
before_script:
|
||||
- |
|
||||
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
|
||||
IMG_TAG=":latest"
|
||||
else
|
||||
IMG_TAG=":$CI_COMMIT_REF_SLUG"
|
||||
fi
|
||||
- docker login -u "$HARBOR_USERNAME" -p "$HARBOR_PASSWORD" $HARBOR_URL
|
||||
|
||||
# 编译阶段任务
|
||||
build-arm64:
|
||||
stage: build
|
||||
script:
|
||||
- export
|
||||
- env
|
||||
- docker buildx build --platform=linux/arm64 --pull -t "$IMG_URL$IMG_TAG-linux-arm64" . --push
|
||||
|
||||
build-amd64:
|
||||
stage: build
|
||||
script:
|
||||
- docker buildx build --platform=linux/amd64 --pull -t "$IMG_URL$IMG_TAG-linux-amd64" . --push
|
||||
|
||||
build-artifact:
|
||||
stage: build
|
||||
needs: [build-amd64, build-arm64]
|
||||
script:
|
||||
- docker manifest create "$IMG_URL$IMG_TAG" "$IMG_URL$IMG_TAG-linux-arm64" "$IMG_URL$IMG_TAG-linux-amd64"
|
||||
- docker manifest push "$IMG_URL$IMG_TAG"
|
||||
|
||||
# 测试阶段任务
|
||||
test:
|
||||
stage: test
|
||||
script:
|
||||
- docker run --rm --platform=linux/arm64 "$IMG_URL$IMG_TAG" /bin/uname -a
|
||||
- docker run --rm --platform=linux/amd64 "$IMG_URL$IMG_TAG" /bin/uname -a
|
||||
|
||||
# 部署阶段任务
|
||||
deploy:
|
||||
stage: deploy
|
||||
script:
|
||||
- echo "deploy stage"
|
||||
-80
@@ -1,80 +0,0 @@
|
||||
# Ver: 1.9 by Endial Fang (endial@126.com)
|
||||
#
|
||||
|
||||
# 默认变量 ========================================================================
|
||||
# 该部分变量为系统根据编译命令默认设置
|
||||
|
||||
# `TARGETPLATFORM`:构建后的目标平台信息。如 `linux/amd64`,`linux/arm/v7`,`windows/amd64`
|
||||
# `TARGETOS`:目标平台信息(TARGETPLATFORM)中的操作系统部分,如:`linux`、`windows`
|
||||
# `TARGETARCH`:目标平台信息(TARGETPLATFORM)中的平台架构部分,如:`amd64`、`arm`
|
||||
# `TARGETVARIANT`:目标平台信息(TARGETPLATFORM)中的版本变体部分,如:`v7`
|
||||
# `BUILDPLATFORM`:用于构建的节点平台信息
|
||||
# `BUILDOS`:用于构建的节点平台信息(BUILDPLATFORM)中的操作系统部分
|
||||
# `BUILDARCH`用于构建的节点平台信息(BUILDPLATFORM)中的平台架构部分
|
||||
# `BUILDVARIANT`用于构建的节点平台信息(BUILDPLATFORM)中的版本变体部分
|
||||
|
||||
# 可变参数 ========================================================================
|
||||
# 该部分变量,在编译命令中通过 `--build-arg` 传入;如果未设置,则使用下面对应的默认值
|
||||
|
||||
# 设置当前应用名称及版本
|
||||
ARG APP_NAME=dBuilder
|
||||
ARG APP_VER=12
|
||||
|
||||
# 设置默认仓库地址,默认为本地仓库;定义时需要包含末尾的`/`
|
||||
ARG REGISTRY_URL="docker.colovu.com/"
|
||||
|
||||
# 设置 apt-get 源:default / ustc / aliyun
|
||||
ARG APT_SOURCE=aliyun
|
||||
|
||||
# 编译镜像时指定用于加速的本地软件包存储服务器地址
|
||||
ARG LOCAL_URL=""
|
||||
|
||||
|
||||
# 1. 生成镜像 =====================================================================
|
||||
FROM --platform=${TARGETPLATFORM:-linux/amd64} ${REGISTRY_URL}colovu/debian:${APP_VER}
|
||||
|
||||
# 声明需要使用的全局可变参数
|
||||
ARG APP_NAME
|
||||
ARG APP_VER
|
||||
ARG REGISTRY_URL
|
||||
ARG APT_SOURCE
|
||||
ARG LOCAL_URL
|
||||
ARG TARGETARCH
|
||||
|
||||
LABEL \
|
||||
"Version"="v${APP_VER}" \
|
||||
"Description"="Docker image for Builder based on Debian." \
|
||||
"Github"="https://github.com/colovu/docker-dbuilder" \
|
||||
"Vendor"="Endial Fang (endial@126.com)"
|
||||
|
||||
|
||||
# 选择软件包源(Optional),以加速后续软件包安装
|
||||
RUN select_source ${APT_SOURCE}
|
||||
|
||||
# 以下命令安装的软件包
|
||||
# apt-transport-https apt-utils binutils binutils-common
|
||||
# binutils-x86-64-linux-gnu build-essential bzip2 ca-certificates cmake
|
||||
# cmake-data cpp cpp-8 curl dirmngr distro-info-data dpkg-dev g++ g++-8 gcc
|
||||
# gcc-8 git git-man gnupg gnupg-l10n gnupg-utils gpg gpg-agent gpg-wks-client
|
||||
# gpg-wks-server gpgconf gpgsm iproute2 iputils-ping libapt-inst2.0
|
||||
# libarchive13 libasan5 libassuan0 libatomic1 libbinutils libc-dev-bin
|
||||
# libc6-dev libcap2 libcap2-bin libcc1-0 libcmocka-dev libcmocka0
|
||||
# libcurl3-gnutls libcurl4 libdpkg-perl libelf1 liberror-perl libexpat1
|
||||
# libgcc-8-dev libgdbm-compat4 libgdbm6 libglib2.0-0 libgomp1 libgssapi-krb5-2
|
||||
# libicu63 libisl19 libitm1 libjsoncpp1 libk5crypto3 libkeyutils1 libkrb5-3
|
||||
# libkrb5support0 libksba8 libldap-2.4-2 libldap-common liblsan0 libmnl0
|
||||
# libmpc3 libmpdec2 libmpfr6 libmpx2 libncurses6 libnghttp2-14 libnpth0
|
||||
# libpcre2-8-0 libperl5.28 libprocps7 libpsl5 libpython3-stdlib
|
||||
# libpython3.7-minimal libpython3.7-stdlib libquadmath0 libreadline7 librhash0
|
||||
# librtmp1 libsasl2-2 libsasl2-modules-db libsqlite3-0 libssh2-1 libssl-dev
|
||||
# libssl1.1 libstdc++-8-dev libtsan0 libubsan1 libuv1 libxml2 libxtables12
|
||||
# linux-libc-dev lsb-base lsb-release make mime-support nano net-tools openssl
|
||||
# patch perl perl-modules-5.28 pinentry-curses pkg-config procps python3
|
||||
# python3-minimal python3.7 python3.7-minimal readline-common sudo wget
|
||||
# xz-utils
|
||||
RUN install_pkg sudo wget curl git ca-certificates iproute2 net-tools nano dpkg gnupg \
|
||||
dirmngr apt-utils apt-transport-https lsb-release iputils-ping \
|
||||
build-essential cmake libcmocka-dev pkg-config libssl1.1 libssl-dev \
|
||||
libtool libltdl7 libltdl-dev
|
||||
|
||||
CMD []
|
||||
@@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 Endial Fang (endial@126.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -1,55 +0,0 @@
|
||||
# Ver: 1.11 by Endial Fang (endial@126.com)
|
||||
#
|
||||
# 当前 Docker 镜像的编译脚本
|
||||
|
||||
# 定义镜像名称
|
||||
image_name :=colovu/dbuilder
|
||||
|
||||
# 定义默认镜像仓库地址
|
||||
REGISTRY_URL :=docker.colovu.com
|
||||
|
||||
# 定义系统默认使用的源服务器,包含:default / ustc / aliyun
|
||||
APT_SOURCE :=aliyun
|
||||
|
||||
# 定义镜像TAG,类似:
|
||||
# <镜像名>:<分支名>-<7位Git ID> # Git 仓库且无文件修改直接编译
|
||||
# <镜像名>:<分支名>-<年月日>-<时分秒> # Git 仓库有文件修改后的编译
|
||||
# <镜像名>:latest-<年月日>-<时分秒> # 非 Git 仓库编译
|
||||
current_subversion:=$(shell if [ ! `git status >/dev/null 2>&1` ]; then git rev-parse --short HEAD; else date +%y%m%d-%H%M%S; fi)
|
||||
image_tag:=$(shell if [ ! `git status >/dev/null 2>&1` ]; then git rev-parse --abbrev-ref HEAD | sed -e 's/master/latest/'; else echo "latest"; fi)-$(current_subversion)
|
||||
|
||||
build-arg:=--build-arg REGISTRY_URL=$(REGISTRY_URL)
|
||||
build-arg+=--build-arg APT_SOURCE=$(APT_SOURCE)
|
||||
|
||||
# 设置本地下载服务器路径,加速调试时的本地编译速度
|
||||
local_ip:=`echo "en0 eth0" | xargs -n1 ip addr show 2>/dev/null | grep inet | grep -v 127.0.0.1 | grep -v inet6 | tr "/" " " | awk '{print $$2}'`
|
||||
build-arg+=--build-arg LOCAL_URL=http://$(local_ip)/dist-files
|
||||
|
||||
.PHONY: build clean clearclean upgrade
|
||||
|
||||
# 屏蔽 "Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them"
|
||||
export DOCKER_SCAN_SUGGEST=false
|
||||
|
||||
build:
|
||||
@echo "Build $(image_name):$(image_tag)"
|
||||
@docker build --progress plain --force-rm $(build-arg) -t $(image_name):$(image_tag) .
|
||||
@echo "Add tag: $(image_name):latest"
|
||||
@docker tag $(image_name):$(image_tag) $(image_name):latest
|
||||
@echo "Build complete"
|
||||
|
||||
# 清理悬空的镜像(无TAG)及停止的容器
|
||||
clearclean: clean
|
||||
@echo "Clean untaged images and stoped containers..."
|
||||
@docker ps -a | grep "Exited" | awk '{print $$1}' | sort -u | xargs -L 1 docker rm
|
||||
@docker images | grep '<none>' | awk '{print $$3}' | sort -u | xargs -L 1 docker rmi -f
|
||||
|
||||
# 为了防止删除前缀名相同的镜像,在过滤条件中加入一个空格进行过滤
|
||||
clean:
|
||||
@echo "Clean all images for current application..."
|
||||
@docker images | grep "$(image_name) " | awk '{print $$3}' | sort -u | xargs -L 1 docker rmi -f
|
||||
|
||||
# 更新所有 colovu 仓库的镜像
|
||||
upgrade:
|
||||
@echo "Upgrade all images..."
|
||||
@docker images | grep 'colovu' | grep -v '<none>' | grep -v "latest-" | awk '{print $$1":"$$2}' | sort -u | xargs -L 1 docker pull
|
||||
|
||||
@@ -1,96 +1,3 @@
|
||||
# Builder
|
||||
|
||||
预安装常用工具及编译工具的镜像。
|
||||
|
||||
该镜像为基于 Debian 系统的 Builder 环境,主要用于在使用多阶段方式制作镜像时,进行软件源代码的下载、编译等预处理操作。预安装软件包节省软件包下载及更新时间。
|
||||
|
||||
|
||||
**版本信息:**
|
||||
|
||||
- latest
|
||||
|
||||
**镜像信息:**
|
||||
|
||||
* 镜像地址:
|
||||
- 阿里云: registry.cn-shenzhen.aliyuncs.com/colovu/dbuilder:latest
|
||||
- DockerHub:colovu/dbuilder:latest
|
||||
- Colovu Registry: docker.colovu.com/colovu/dbuilder:latest
|
||||
- 依赖镜像:colovu/debian:latest
|
||||
|
||||
> 后续相关命令行默认使用`[Colovu Registry](https://docker.colovu.com)`镜像服务器做说明
|
||||
|
||||
## TL;DR
|
||||
|
||||
Docker 快速启动命令:
|
||||
|
||||
```shell
|
||||
# 从 Registry 服务器下载镜像并启动
|
||||
$ docker run -it docker.colovu.com/colovu/dbuilder /bin/bash
|
||||
```
|
||||
|
||||
## 数据卷
|
||||
|
||||
镜像默认提供以下数据卷定义:
|
||||
|
||||
```shell
|
||||
/srv/data # 工作目录
|
||||
/srv/conf # 配置文件目录
|
||||
```
|
||||
|
||||
## 使用方式
|
||||
|
||||
使用`--from=0`方式:
|
||||
|
||||
```dockerfile
|
||||
# 预编译阶段 ===============================
|
||||
FROM docker.colovu.com/colovu/dbuilder:latest
|
||||
|
||||
WORKDIR /tmp
|
||||
|
||||
# 相关下载/解压/编译操作
|
||||
|
||||
# ... 省略
|
||||
|
||||
# 镜像生成阶段 ==============================
|
||||
FROM scratch
|
||||
# 从编译阶段的中拷贝编译结果到当前镜像中(例如:编译的应用直接安装至/usr/local时)
|
||||
COPY --from=0 /usr/local/ /usr/local
|
||||
|
||||
# ... 省略其它操作
|
||||
|
||||
# 镜像命令
|
||||
CMD []
|
||||
```
|
||||
|
||||
使用`--from=name`方式:
|
||||
|
||||
```dockerfile
|
||||
# 预编译阶段。命名为`builder` ==================
|
||||
FROM docker.colovu.com/colovu/dbuilder:latest as builder
|
||||
|
||||
WORKDIR /tmp
|
||||
|
||||
# 相关下载/解压/编译操作
|
||||
|
||||
# ... 省略
|
||||
|
||||
# 镜像生成阶段 ==============================
|
||||
FROM scratch
|
||||
# 从编译阶段的中拷贝编译结果到当前镜像中(例如:编译的应用直接安装至/usr/local时)
|
||||
COPY --from=builder /usr/local/ /usr/local
|
||||
|
||||
# ... 省略其它操作
|
||||
|
||||
# 镜像命令
|
||||
CMD []
|
||||
```
|
||||
|
||||
使用该方式的优势:
|
||||
|
||||
- 因系统相关软件包已更新,工具已经预先安装,不需要在每次编译镜像时耗费大量时间在类似重复工作上
|
||||
- 不用安装、删除临时软件,放置生成多余的垃圾文件;预编译阶段的内容使用完即丢弃,不会对镜像大小产生影响
|
||||
- 没有相关的中间操作步骤,不会产生多余的镜像分层
|
||||
|
||||
----
|
||||
|
||||
本文原始来源 [Endial Fang](https://github.com/colovu) @ [Github.com](https://github.com)
|
||||
停止维护 v11 版本.
|
||||
|
||||
Reference in New Issue
Block a user