variantdev/modmod:variant.mod:
provisioners: files: Dockerfile: source: Dockerfile.tpl arguments: helm_version: "{{ .helm.version }}" helm: releasesFrom: githubReleases: source: helm/helm version: "> 1.0.0"
Dockerfile(Updated automatically by mod:
FROM alpine:3.9 ARG HELM_VERSION=2.14.3 ADD [***]{HELM_FILE_NAME} /tmp RUN tar -zxvf /tmp/${HELM_FILE_NAME} -C /tmp \ && mv /tmp/linux-amd64/helm /bin/helm \ && rm -rf /tmp/* \ && /bin/helm init --client-only
Run mod build and see mod retrieves the latest version number of helm that satisfies the semver constraint > 1.0.0 and updates your Dockerfile by rendering Dockerfile.tpl accordingly.
mod and submit a pull request to update everything managed via mod automaticallymod up --build --pull-request --title "Initialize this repository" in response to "repository created" webhook and submit a PR for initializationmod create myorg/mytemplate-repo myorg/mynew-repo --build --pull-requestmod is basically the package manager for any make/variant-based project with git support. mod create creates a new project from a template repo by rendering all the gomplate-like template on init.
mod up updates dependencies of the project originally created from the template repo, re-rendering required files.
You can define one or more stages so that mod can update stages one by one promoting revisions tested with previous stages to later stages.
Let's say you want three stages, development, staging and production, where development stage has test envirnoment associated, and staging stage has manual and stress environemnts, and production stage has prod environment associated.
stages: - name: development environments: - test - name: staging environments: - qa - stress - name: production environments: - prod provisioners: files: helmfile: path: states/helmfile.{{ .stage.environment }}.yaml source: templates/helmfile.yaml.tpl arguments: MYAPP_VERSION: "{{ .stage.dependencies.myapp.version }}" dependencies: myapp: releasesFrom: dockerImageTags: source: example.com/myorg/myapp version: "> 0.1.0"
When there's any update in dependencies, you will firstly deploy it to the test environment by running:
$ mod up development --build --pull-request
This command updates the list of dependencies, and updates the development stage if and only if there were one or more new versions of dependencies.
mod delegates the actual update for the development stage to your CD system. That's done by mod generating the desired state of the development stage by executing the file provider defined in the config.
In the above example, the desired state is rendered from the template file located at states/helmfile.test.yaml, whose content is generated by rendering the go template templates/helmfile.yaml.tpl, as defined in the config.
The environment name listed in stage's environments is available for use in file provisioner's arguments, so that you can generate the desired state depending on the environment included in the stage.
For development stage, path: states/helmfile.{{ .stage.environment }}.yaml is evaluated to states/helmfile.test.yaml, which is why mod up development --build updates states/helmfile.test.yaml.
In addition to generating the desired state, due to that the --pull-request flag is provided, mod automatically creates a pull request to update a gitops config repo, which is then reviewed and merged by your team.
Once the pull request has been merged and deployed, you can run the below command to promote the previous deployment passed the test stage to the next staging stage:
$ mod up staging --build --pull-request
For the above example, updating staging stage results in updating states/helmfile.qa.yaml and states/helmfile.stress.yaml.
For example, merging the pull request updating those two files should result in updating qa and stress Kubernetes clusters, so that the new revision can be tested by respective teams.
After your QA team finished testing it in qa and your peformance team finished testing it in the stress environments, you can finally ship it to production:
$ mod up production --build --pull-request
As you might have guessed, this updates states/helmfile.prod.yaml, and merging the pull request updating it should trigger a production deployment.
Navigate to the following examples to see practical usage of mod:
Dockerfile and .circleci/config.yml on new Golang releaseregexpReplace provisionerregexpReplace updates any text file like Dockerfile with regular expressions.
Let's say you want to automate updating the base image of the below Dockerfile:
FROM helmfile:0.94.0 RUN echo hello
You can write a variant.mod file like the below so that mod knows where is the image tag to be updated:
yamlprovisioners: regexpReplace: Dockerfile: from: "(FROM helmfile:)(\\S+)(\\s+)" to: "${1}{{.Dependencies.helmfile.version}}${3}" dependencies: helmfile: releasesFrom: dockerImageTags: source: quay.io/roboll/helmfile version: "> 0.94.0"
docker executable provisionerSetting provisioners.executables.NAME.platforms[].docker allows you to run mod exec -- NAME $args where the executable is backed by a docker image which is managed by mod.
variant.mod:
parameters: defaults: version: "1.12.6" provisioners: executables: dockergo: platforms: # Adds $VARIANT_MOD_PATH/mod/cache/CACHE_KEY/dockergo to $PATH # Or its shim at $VARIANT_MOD_PATH/MODULE_NAME/shims - docker: command: go image: golang tag: '{{.version}}' volume: - $PWD:/work workdir: /work
console$ go version go version go1.12.7 darwin/amd64 $ mod exec -- dockergo version go version go1.12.6 linux/amd64
The following template functions are available for use within template provisioners:
{{ hasKey .Foo.Bar "mykey" }} returns true if .Foo.Bar is a map[string]interface{} and the value for the key mykey is set.{{ trimSpace .Str }} removes spaces, tabs, and new-lines from .Str
``探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
在 Linux 系统配置镜像服务
在 Docker Desktop 配置镜像
Docker Compose 项目配置
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
MacOS OrbStack 容器配置
在宝塔面板一键配置镜像
Synology 群晖 NAS 配置
飞牛 fnOS 系统配置镜像
极空间 NAS 系统配置服务
爱快 iKuai 路由系统配置
绿联 NAS 系统配置镜像
QNAP 威联通 NAS 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
无需登录使用专属域名
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
免费版仅支持 Docker Hub 访问,不承诺可用性和速度;专业版支持更多镜像源,保证可用性和稳定速度,提供优先客服响应。
专业版支持 docker.io、gcr.io、ghcr.io、registry.k8s.io、nvcr.io、quay.io、mcr.microsoft.com、docker.elastic.co 等;免费版仅支持 docker.io。
当返回 402 Payment Required 错误时,表示流量已耗尽,需要充值流量包以恢复服务。
通常由 Docker 版本过低导致,需要升级到 20.x 或更高版本以支持 V2 协议。
先检查 Docker 版本,版本过低则升级;版本正常则验证镜像信息是否正确。
使用 docker tag 命令为镜像打上新标签,去掉域名前缀,使镜像名称更简洁。
来自真实用户的反馈,见证轩辕镜像的优质服务