Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 265fa3ba6f | |||
| 2cb1ef14a8 | |||
| 9879e9dea0 | |||
| 63578e31fe | |||
| 10b6b564cb | |||
| ab90d73525 |
@@ -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,74 +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 服务(这里使用Runner中配置的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_NAME"
|
||||
fi
|
||||
- docker login -u "$HARBOR_USERNAME" -p "$HARBOR_PASSWORD" $HARBOR_URL
|
||||
|
||||
# 环境变量信息
|
||||
env-variables:
|
||||
stage: .pre
|
||||
script:
|
||||
- export
|
||||
|
||||
# 编译阶段任务
|
||||
build-arm64:
|
||||
stage: build
|
||||
tags:
|
||||
- arm64
|
||||
script:
|
||||
- docker buildx build --platform=linux/arm64 --pull -t "$IMG_URL$IMG_TAG-linux-arm64" . --push
|
||||
- docker rmi "$IMG_URL$IMG_TAG-linux-arm64"
|
||||
|
||||
build-amd64:
|
||||
stage: build
|
||||
tags:
|
||||
- amd64
|
||||
script:
|
||||
- docker buildx build --platform=linux/amd64 --pull -t "$IMG_URL$IMG_TAG-linux-amd64" . --push
|
||||
- docker rmi "$IMG_URL$IMG_TAG-linux-amd64"
|
||||
|
||||
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"
|
||||
- docker manifest rm "$IMG_URL$IMG_TAG"
|
||||
|
||||
# 测试阶段任务
|
||||
test:
|
||||
stage: test
|
||||
script:
|
||||
- docker run --rm --platform=linux/arm64 "$IMG_URL$IMG_TAG" go version
|
||||
- sleep 1 && docker rmi -f "$IMG_URL$IMG_TAG"
|
||||
- docker run --rm --platform=linux/amd64 "$IMG_URL$IMG_TAG" go version
|
||||
- sleep 1 && docker rmi -f "$IMG_URL$IMG_TAG"
|
||||
|
||||
# 部署阶段任务
|
||||
deploy:
|
||||
stage: deploy
|
||||
script:
|
||||
- echo "deploy stage"
|
||||
-86
@@ -1,86 +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=golang
|
||||
ARG APP_VER=1.20.7
|
||||
|
||||
# 设置默认仓库地址,默认为本地仓库;定义时需要包含末尾的`/`
|
||||
ARG REGISTRY_URL="docker.colovu.com/"
|
||||
|
||||
# 设置 apt-get 源:default / ustc / aliyun
|
||||
ARG APT_SOURCE=aliyun
|
||||
|
||||
# 编译镜像时指定用于加速的本地软件包存储服务器地址
|
||||
ARG LOCAL_URL="http://local.colovu.com/dist"
|
||||
|
||||
# 0. 预处理 ======================================================================
|
||||
FROM --platform=${TARGETPLATFORM:-linux/amd64} ${REGISTRY_URL}colovu/dbuilder:12 as builder
|
||||
|
||||
# 声明需要使用的全局可变参数
|
||||
ARG APP_NAME
|
||||
ARG APP_VER
|
||||
ARG LOCAL_URL
|
||||
ARG TARGETARCH
|
||||
|
||||
# 下载并解压软件包
|
||||
# https://golang.google.cn/dl/go1.20.7.linux-amd64.tar.gz
|
||||
# https://golang.google.cn/dl/go1.20.7.linux-arm64.tar.gz
|
||||
RUN set -eux; \
|
||||
appName=go${APP_VER}.linux-${TARGETARCH}.tar.gz; \
|
||||
[ -n ${LOCAL_URL} ] && localURL=${LOCAL_URL}/golang; \
|
||||
appUrls="${localURL:-} \
|
||||
https://golang.google.cn/dl \
|
||||
"; \
|
||||
download_pkg unpack ${appName} "${appUrls}"; \
|
||||
mv "/tmp/go" /usr/local/${APP_NAME};
|
||||
|
||||
# 1. 生成镜像 =====================================================================
|
||||
FROM --platform=${TARGETPLATFORM:-linux/amd64} ${REGISTRY_URL}colovu/debian:12
|
||||
|
||||
# 声明需要使用的全局可变参数(ARG声明的变量仅编译打包阶段有效)
|
||||
ARG APP_NAME
|
||||
ARG APP_VER
|
||||
|
||||
# 定义应用的基础信息变量(ENV声明的变量实例化后容器内有效)
|
||||
ENV APP_NAME=${APP_NAME} \
|
||||
APP_VER=${APP_VER} \
|
||||
APP_EXEC=go \
|
||||
APP_BASE=/usr/local/${APP_NAME}
|
||||
|
||||
# 增加应用可执行文件及库文件搜索路径
|
||||
ENV PATH="${PATH}:/usr/local/${APP_NAME}/bin"
|
||||
|
||||
LABEL \
|
||||
"Version"="v${APP_VER}" \
|
||||
"Description"="Docker image for ${APP_NAME}." \
|
||||
"Github"="https://github.com/colovu/docker-${APP_NAME}" \
|
||||
"Vendor"="Endial Fang (endial@126.com)"
|
||||
|
||||
# 从预处理过程中拷贝软件包(Optional),可以使用阶段编号或阶段命名定义来源
|
||||
COPY --from=builder /usr/local/${APP_NAME} /usr/local/${APP_NAME}
|
||||
|
||||
RUN set -eux; \
|
||||
\
|
||||
# 执行后处理脚本,并验证安装的应用
|
||||
${APP_EXEC} version;
|
||||
|
||||
# 应用程序的启动命令,可为应用程序可执行命令或脚本
|
||||
# 必须使用非守护进程方式运行
|
||||
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,52 +0,0 @@
|
||||
# Ver: 1.11 by Endial Fang (endial@126.com)
|
||||
#
|
||||
# 当前 Docker 镜像的编译脚本
|
||||
|
||||
# 定义镜像名称
|
||||
image_name :=colovu/golang
|
||||
|
||||
# 定义默认镜像仓库地址
|
||||
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/' | sed -e 's/main/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.colovu.com/dist
|
||||
|
||||
.PHONY: build clean clearclean upgrade
|
||||
|
||||
build:
|
||||
@echo "Build $(image_name):$(image_tag)"
|
||||
@docker buildx 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,43 +1,3 @@
|
||||
# 简介
|
||||
|
||||
针对 Golang 的 Docker 镜像,用于提供基础 Golang 开发环境。
|
||||
|
||||
使用说明可参考:[官方说明](https://golang.google.cn/doc/#)
|
||||
二进制文件下载:[Golang.CN](https://golang.google.cn/dl/)
|
||||
|
||||
<img src="img/go-logo-blue.svg" alt="Golang-logo" style="zoom: 150%;" />
|
||||
|
||||
**Golang 版本信息:**
|
||||
|
||||
- 1.20.7
|
||||
|
||||
**镜像信息:**
|
||||
|
||||
* 镜像地址:
|
||||
* 阿里云: registry.cn-shenzhen.aliyuncs.com/colovu/golang:latest
|
||||
* Docker Hub: colovu/golang:latest
|
||||
* Colovu Registry: docker.colovu.com/colovu/golang:latest
|
||||
* 依赖镜像:colovu/debian:12
|
||||
|
||||
> 后续相关命令行默认使用`[Colovu Registry](https://docker.colovu.com)`镜像服务器做说明
|
||||
|
||||
## TL;DR
|
||||
|
||||
基本验证命令:
|
||||
|
||||
```shell
|
||||
# 11之前的版本
|
||||
$ docker run -it --rm docker.colovu.com/colovu/golang:latest go version
|
||||
|
||||
# 11之后的版本
|
||||
$ docker run -it --rm docker.colovu.com/colovu/golang:latest go version
|
||||
```
|
||||
|
||||
## 更新记录
|
||||
|
||||
- 2023/8/21: 添加 Golang 版本为 1.20.7
|
||||
|
||||
----
|
||||
|
||||
本文原始来源 [Endial Fang](https://github.com/colovu) @ [Github.com](https://github.com)
|
||||
|
||||
停止维护 v1.20 版本.
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
<svg height="78" viewBox="0 0 207 78" width="207" xmlns="http://www.w3.org/2000/svg"><g fill="#00acd7" fill-rule="evenodd"><path d="m16.2 24.1c-.4 0-.5-.2-.3-.5l2.1-2.7c.2-.3.7-.5 1.1-.5h35.7c.4 0 .5.3.3.6l-1.7 2.6c-.2.3-.7.6-1 .6z"/><path d="m1.1 33.3c-.4 0-.5-.2-.3-.5l2.1-2.7c.2-.3.7-.5 1.1-.5h45.6c.4 0 .6.3.5.6l-.8 2.4c-.1.4-.5.6-.9.6z"/><path d="m25.3 42.5c-.4 0-.5-.3-.3-.6l1.4-2.5c.2-.3.6-.6 1-.6h20c.4 0 .6.3.6.7l-.2 2.4c0 .4-.4.7-.7.7z"/><g transform="translate(55)"><path d="m74.1 22.3c-6.3 1.6-10.6 2.8-16.8 4.4-1.5.4-1.6.5-2.9-1-1.5-1.7-2.6-2.8-4.7-3.8-6.3-3.1-12.4-2.2-18.1 1.5-6.8 4.4-10.3 10.9-10.2 19 .1 8 5.6 14.6 13.5 15.7 6.8.9 12.5-1.5 17-6.6.9-1.1 1.7-2.3 2.7-3.7-3.6 0-8.1 0-19.3 0-2.1 0-2.6-1.3-1.9-3 1.3-3.1 3.7-8.3 5.1-10.9.3-.6 1-1.6 2.5-1.6h36.4c-.2 2.7-.2 5.4-.6 8.1-1.1 7.2-3.8 13.8-8.2 19.6-7.2 9.5-16.6 15.4-28.5 17-9.8 1.3-18.9-.6-26.9-6.6-7.4-5.6-11.6-13-12.7-22.2-1.3-10.9 1.9-20.7 8.5-29.3 7.1-9.3 16.5-15.2 28-17.3 9.4-1.7 18.4-.6 26.5 4.9 5.3 3.5 9.1 8.3 11.6 14.1.6.9.2 1.4-1 1.7z"/><path d="m107.2 77.6c-9.1-.2-17.4-2.8-24.4-8.8-5.9-5.1-9.6-11.6-10.8-19.3-1.8-11.3 1.3-21.3 8.1-30.2 7.3-9.6 16.1-14.6 28-16.7 10.2-1.8 19.8-.8 28.5 5.1 7.9 5.4 12.8 12.7 14.1 22.3 1.7 13.5-2.2 24.5-11.5 33.9-6.6 6.7-14.7 10.9-24 12.8-2.7.5-5.4.6-8 .9zm23.8-40.4c-.1-1.3-.1-2.3-.3-3.3-1.8-9.9-10.9-15.5-20.4-13.3-9.3 2.1-15.3 8-17.5 17.4-1.8 7.8 2 15.7 9.2 18.9 5.5 2.4 11 2.1 16.3-.6 7.9-4.1 12.2-10.5 12.7-19.1z" fill-rule="nonzero"/></g></g></svg>
|
||||
|
Before Width: | Height: | Size: 1.4 KiB |
@@ -1 +0,0 @@
|
||||
<svg height="78" viewBox="0 0 207 78" width="207" xmlns="http://www.w3.org/2000/svg"><g fill="#ffffff" fill-rule="evenodd"><path d="m16.2 24.1c-.4 0-.5-.2-.3-.5l2.1-2.7c.2-.3.7-.5 1.1-.5h35.7c.4 0 .5.3.3.6l-1.7 2.6c-.2.3-.7.6-1 .6z"/><path d="m1.1 33.3c-.4 0-.5-.2-.3-.5l2.1-2.7c.2-.3.7-.5 1.1-.5h45.6c.4 0 .6.3.5.6l-.8 2.4c-.1.4-.5.6-.9.6z"/><path d="m25.3 42.5c-.4 0-.5-.3-.3-.6l1.4-2.5c.2-.3.6-.6 1-.6h20c.4 0 .6.3.6.7l-.2 2.4c0 .4-.4.7-.7.7z"/><g transform="translate(55)"><path d="m74.1 22.3c-6.3 1.6-10.6 2.8-16.8 4.4-1.5.4-1.6.5-2.9-1-1.5-1.7-2.6-2.8-4.7-3.8-6.3-3.1-12.4-2.2-18.1 1.5-6.8 4.4-10.3 10.9-10.2 19 .1 8 5.6 14.6 13.5 15.7 6.8.9 12.5-1.5 17-6.6.9-1.1 1.7-2.3 2.7-3.7-3.6 0-8.1 0-19.3 0-2.1 0-2.6-1.3-1.9-3 1.3-3.1 3.7-8.3 5.1-10.9.3-.6 1-1.6 2.5-1.6h36.4c-.2 2.7-.2 5.4-.6 8.1-1.1 7.2-3.8 13.8-8.2 19.6-7.2 9.5-16.6 15.4-28.5 17-9.8 1.3-18.9-.6-26.9-6.6-7.4-5.6-11.6-13-12.7-22.2-1.3-10.9 1.9-20.7 8.5-29.3 7.1-9.3 16.5-15.2 28-17.3 9.4-1.7 18.4-.6 26.5 4.9 5.3 3.5 9.1 8.3 11.6 14.1.6.9.2 1.4-1 1.7z"/><path d="m107.2 77.6c-9.1-.2-17.4-2.8-24.4-8.8-5.9-5.1-9.6-11.6-10.8-19.3-1.8-11.3 1.3-21.3 8.1-30.2 7.3-9.6 16.1-14.6 28-16.7 10.2-1.8 19.8-.8 28.5 5.1 7.9 5.4 12.8 12.7 14.1 22.3 1.7 13.5-2.2 24.5-11.5 33.9-6.6 6.7-14.7 10.9-24 12.8-2.7.5-5.4.6-8 .9zm23.8-40.4c-.1-1.3-.1-2.3-.3-3.3-1.8-9.9-10.9-15.5-20.4-13.3-9.3 2.1-15.3 8-17.5 17.4-1.8 7.8 2 15.7 9.2 18.9 5.5 2.4 11 2.1 16.3-.6 7.9-4.1 12.2-10.5 12.7-19.1z" fill-rule="nonzero"/></g></g></svg>
|
||||
|
Before Width: | Height: | Size: 1.4 KiB |
Reference in New Issue
Block a user