-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c9c65ba
commit 5675da9
Showing
3 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Nodejs Image | ||
on: | ||
workflow_dispatch: | ||
|
||
env: | ||
DOCKER_REGISTRY: ghcr.io | ||
IMAGE_NAME: ayaka-notes/image-cn/node | ||
|
||
jobs: | ||
clean-node-texlive: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Delete 'untaged' containers | ||
uses: snok/container-retention-policy@v2 | ||
with: | ||
image-names: node/*,node | ||
cut-off: 1 min ago UTC | ||
account-type: org | ||
org-name: ayaka-notes | ||
untagged-only: true | ||
token: ${{ secrets.ORGTOKEN }} | ||
|
||
build-image: | ||
runs-on: ubuntu-latest | ||
needs: clean-node-texlive | ||
strategy: | ||
fail-fast: false | ||
max-parallel: 3 | ||
matrix: | ||
node-version: [18.18.2, 16.13.0] | ||
name: Nodejs ${{ matrix.tex-version }} | ||
steps: | ||
- name: "Checkout GitHub Action" | ||
id: checkout | ||
uses: actions/checkout@main | ||
|
||
- name: "Login to GitHub Container Registry" | ||
id: docker_login | ||
uses: docker/[email protected] | ||
with: | ||
registry: ${{env.DOCKER_REGISTRY}} | ||
username: ${{github.actor}} | ||
password: ${{secrets.GITHUB_TOKEN}} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/[email protected] | ||
with: | ||
context: ./node | ||
file: ./node/Dockerfile | ||
push: true | ||
tags: ${{ env.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.tex-version }} | ||
# 参数 | ||
build-args: | | ||
nodetag=${{ matrix.node-version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,11 @@ | ||
# image-cn | ||
适合在国区使用的Docker镜像(已完成换源操作) | ||
|
||
众所周知,在下载Dockerhub、ghcr、的镜像,对于各显神通的开发者已经不是大问题(各路镜像仓库等),但是问题最多的往往出现在`Docker Build`这个步骤。`Docker Build`本身是可以支持`Proxy`等各种代理,但是问题很多。对于`apt-get`等命令,使用`Proxy`可能导致各种崩溃,不使用又可能导致速度爆炸慢。更何况`Proxy`的还只有Linux支持连接到本地的代理服务,总之问题往往很多,很难搞定。 | ||
|
||
至于换源?一般来说Dockerhub下载的镜像都是原版的镜像,加上又没有合适的换源脚本,开发者要目手动开启编辑器换源的,要目自己写脚本去换源。 | ||
|
||
假设有人愿意换源,然后下载了一个换源脚本,发现又需要安装`lsb-release`,然后一搜安装方法,竟然又是`apt-get install lsb-release`,这下闭环了。我当场就是为了`apt`速度慢换源,结果换源又需要依赖`apt`。 | ||
|
||
综上所述,唯一的解决方法就是类似阿里云提供的**海外构建**的方案,把换源的步骤放在海外做,然后把构建好的镜像同步回来,这也是本仓库:适合在国区使用的Docker镜像(已完成换源操作)的目的所在。 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# 使用方法: docker build -t node:latest --build-arg nodetag=18.18.2 . | ||
|
||
ARG nodetag=latest | ||
|
||
FROM node:${nodetag} | ||
|
||
# 此步骤必须在海外机器构件 | ||
RUN apt-get update && apt-get install lsb-release | ||
|
||
# 换源apt | ||
RUN curl -sSL https://linuxmirrors.cn/main.sh -o main.sh \ | ||
&& chmod 755 ./main.sh \ | ||
&& bash main.sh --source mirrors.aliyun.com \ | ||
&& rm -rf ./main.sh \ | ||
&& apt-get update | ||
|
||
# 换源npm | ||
RUN npm config set registry https://registry.npmmirror.com |