Skip to content

Commit 944c1a0

Browse files
authored
Further organize Docker images. (#4)
Further organize Docker images.
1 parent 90f2bd6 commit 944c1a0

5 files changed

Lines changed: 102 additions & 24 deletions

File tree

.github/workflows/docker-build.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,30 +69,40 @@ jobs:
6969
username: ${{ github.actor }}
7070
password: ${{ secrets.GITHUB_TOKEN }}
7171

72-
# ========== A) 构建 chiseled 瘦镜像 ==========
72+
# ========== A) 构建 chiseled 瘦镜像 ==========
7373
- name: Build & push chiseled
7474
uses: docker/build-push-action@v4
7575
with:
7676
context: .
7777
file: build/scripts/Dockerfile
78-
target: chiseled # 关键:只构建 chiseled 阶段
78+
target: chiseled
7979
push: true
8080
tags: |
8181
${{ env.DOCKERHUB_REPO }}:latest
8282
${{ env.DOCKERHUB_REPO }}:${{ steps.set_version.outputs.version }}
8383
${{ env.GHCR_REPO_LC }}:latest
8484
${{ env.GHCR_REPO_LC }}:${{ steps.set_version.outputs.version }}
8585
86+
# ========== B) 构建 secure 镜像 ==========
87+
- name: Build & push debug
88+
uses: docker/build-push-action@v4
89+
with:
90+
context: .
91+
file: build/scripts/Dockerfile
92+
target: secure
93+
push: true
94+
tags: |
95+
${{ env.DOCKERHUB_REPO }}:secure
96+
${{ env.GHCR_REPO_LC }}:secure
97+
8698
# ========== B) 构建 debug 镜像 ==========
8799
- name: Build & push debug
88100
uses: docker/build-push-action@v4
89101
with:
90102
context: .
91103
file: build/scripts/Dockerfile
92-
target: debug # 关键:只构建 debug 阶段
104+
target: debug
93105
push: true
94106
tags: |
95107
${{ env.DOCKERHUB_REPO }}:debug
96-
${{ env.DOCKERHUB_REPO }}:${{ steps.set_version.outputs.version }}-debug
97108
${{ env.GHCR_REPO_LC }}:debug
98-
${{ env.GHCR_REPO_LC }}:${{ steps.set_version.outputs.version }}-debug

README.md

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,10 @@ NOTE: `Job type extensions are not supported at the moment`.
103103
- [Manual Execution](#manual-execution)
104104
- [As a Windows Service](#as-a-windows-service)
105105
- [As a Docker Container](#as-a-docker-container)
106-
- [Debugging creation](#debugging-creation)
107-
- [Production creation](#production-creation)
106+
- [Available Docker Versions](#available-docker-versions)
107+
- [Debug Creation](#debug-creation)
108+
- [Production Environment](#production-environment)
109+
- [Production Environment with Minimum Privileges](#production-environment-with-minimum-privileges)
108110
- [Parameter Description](#parameter-description)
109111
- [Contributing](#contributing)
110112
- [Special Thanks](#special-thanks)
@@ -725,23 +727,43 @@ Available Docker registries:
725727
- <https://github.com/neatFactory/JobAgent/pkgs/container/jobagent>
726728
> Visit <https://hub.docker.com/r/aicrosoft/jobagent> to get the latest Docker image.
727729
728-
### Debugging creation
730+
731+
### Available Docker Versions
732+
| Version | Type | Description |
733+
| :------ | :-------------- | :-------------------------------------------------- |
734+
| 1.2.3.4 | Standard | Root privileges + No shell series |
735+
| latest | Latest Standard | Root privileges + No shell, latest |
736+
| secure | Secure | Minimum privileges + No shell, latest |
737+
| debug | Debug | Root privileges + Shell + JobSamples plugin, latest |
738+
739+
### Debug Creation
729740
```shell
730741
# You can enter the container to perform operations
731742
sudo docker run -d \
732743
--name jobagent-de \
733744
aicrosoft/jobagent:debug
734-
### The DEBUG version of the image already has the JobSamples plugin.
745+
## The DEBUG version image already includes the JobSamples plugin.
746+
```
747+
748+
### Production Environment
749+
```shell
750+
## Create a container.
751+
sudo docker run -d \
752+
--name jobagent \
753+
-v /apps/ja/logs:/app/logs:rw \
754+
-v /apps/ja/plugins:/app/Plugins:rw \
755+
-v /apps/ja/states:/app/states:rw \
756+
aicrosoft/jobagent:latest
735757
```
736758

737-
### Production creation
759+
### Production Environment with Minimum Privileges
738760
```shell
739-
## Pre-create Empty Directories on the Host Machine and Assign Permissions
761+
## Pre-create empty directories on the host machine and assign permissions
740762
sudo mkdir -p /apps/ja/logs /apps/ja/plugins /apps/ja/states
741763
sudo chmod -R 777 /apps/ja
742764
sudo chown -R 65532:65532 /apps/ja
743765

744-
## When creating the container, the plugin directory is empty in the non-DEBUG version.
766+
## Create a container.
745767
sudo docker run -d \
746768
--name jobagent \
747769
-v /apps/ja/logs:/app/logs:rw \

build/scripts/Dockerfile

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,26 @@ RUN mkdir -p /app/states /app/logs /app/Plugins && \
3737
chown -R 65532:65532 /app/states /app/logs
3838

3939
# ==============================================================================
40-
# 阶A:chiseled 瘦镜像(生产用)(chiseled —— 无 sh、无 chmod)
40+
# 阶A:chiseled 瘦镜像(生产用)(chiseled —— 无 sh、无 chmod) 1.2.3.4 | 普通版本 | root权限 + 无shell
4141
# ==============================================================================
4242
FROM mcr.microsoft.com/dotnet/runtime:8.0-jammy-chiseled AS chiseled
4343
WORKDIR /app
44-
# 直接拷过去并把属主改成非 root
44+
COPY --from=build /app .
45+
ENTRYPOINT ["./JobAgent"]
46+
47+
# ==============================================================================
48+
# 阶B:chiseled 瘦镜像(生产用)(chiseled —— 无 sh、无 chmod) secure | 安全版本 | 最小权限 + 无shell
49+
# ==============================================================================
50+
FROM mcr.microsoft.com/dotnet/runtime:8.0-jammy-chiseled AS secure
51+
WORKDIR /app
4552
COPY --from=build --chown=65532:65532 /app .
4653
USER 65532
4754
ENTRYPOINT ["./JobAgent"]
4855

4956
# ==============================================================================
50-
# 阶段B:带 SDK 的 debug 调试镜像(调试/排障用|带 shell)
57+
# 阶段C:带 SDK 的 debug 调试镜像(调试/排障用|带 shell) debug | 测试版本 | root根限 + 有shell + JobSamples插件
5158
# ==============================================================================
5259
FROM mcr.microsoft.com/dotnet/sdk:8.0-jammy AS debug
5360
WORKDIR /app
54-
# 这里不需要改属主,默认 root 即可,方便进去装工具
55-
COPY --from=build /app .
56-
COPY --from=build /plugin .
61+
COPY --from=build /app /plugin ./
5762
ENTRYPOINT ["./JobAgent"]

docs/cn/README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,10 @@ NOTE: `暂时不提供Job类型的扩展`。
104104
- [手动运行](#手动运行)
105105
- [作为 Windows 服务](#作为-windows-服务)
106106
- [Docker 方式](#docker-方式)
107+
- [Docker 的可用版本](#docker-的可用版本)
107108
- [调试创建](#调试创建)
108109
- [生产环境](#生产环境)
110+
- [生产环境 最小权限](#生产环境-最小权限)
109111
- [Docker参数说明](#docker参数说明)
110112
- [贡献](#贡献)
111113
- [特别感谢](#特别感谢)
@@ -724,6 +726,15 @@ install -u # uninstall it
724726
- <https://github.com/neatFactory/JobAgent/pkgs/container/jobagent>
725727
> 访问 <https://hub.docker.com/r/aicrosoft/jobagent> 获取最新的 docker 镜像。
726728
729+
### Docker 的可用版本
730+
| 版本 | 类型 | 说明 |
731+
| ------- | :------- | :----------------------------------------- |
732+
| 1.2.3.4 | 普通版本 | root权限 + 无shell 系列 |
733+
| latest | 普通最新 | root权限 + 无shell ,最新 |
734+
| secure | 安全版本 | 最小权限 + 无shell,最新 |
735+
| debug | 测试版本 | root根限 + 有shell + JobSamples插件 ,最新 |
736+
737+
727738
### 调试创建
728739
```shell
729740
# 可以进到容器中进行操作
@@ -735,12 +746,23 @@ sudo docker run -d \
735746

736747
### 生产环境
737748
```shell
749+
## 创建容器。
750+
sudo docker run -d \
751+
--name jobagent \
752+
-v /apps/ja/logs:/app/logs:rw \
753+
-v /apps/ja/plugins:/app/Plugins:rw \
754+
-v /apps/ja/states:/app/states:rw \
755+
aicrosoft/jobagent:latest
756+
```
757+
758+
### 生产环境 最小权限
759+
```shell
738760
## 在宿主机预建空目录并赋权
739761
sudo mkdir -p /apps/ja/logs /apps/ja/plugins /apps/ja/states
740762
sudo chmod -R 777 /apps/ja
741763
sudo chown -R 65532:65532 /apps/ja
742764

743-
## 创建容器,非DEBUG版本中,插件目录为空
765+
## 创建容器。
744766
sudo docker run -d \
745767
--name jobagent \
746768
-v /apps/ja/logs:/app/logs:rw \

docs/en/Docker.md

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,42 @@ Available Docker registries:
5454
> Visit <https://hub.docker.com/r/aicrosoft/jobagent> to get the latest Docker image.
5555
5656

57-
### Debugging creation
57+
### Available Docker Versions
58+
| Version | Type | Description |
59+
| :------ | :-------------- | :-------------------------------------------------- |
60+
| 1.2.3.4 | Standard | Root privileges + No shell series |
61+
| latest | Latest Standard | Root privileges + No shell, latest |
62+
| secure | Secure | Minimum privileges + No shell, latest |
63+
| debug | Debug | Root privileges + Shell + JobSamples plugin, latest |
64+
65+
### Debug Creation
5866
```shell
5967
# You can enter the container to perform operations
6068
sudo docker run -d \
6169
--name jobagent-de \
6270
aicrosoft/jobagent:debug
63-
### The DEBUG version of the image already has the JobSamples plugin.
71+
## The DEBUG version image already includes the JobSamples plugin.
6472
```
6573

66-
### Production creation
74+
### Production Environment
6775
```shell
68-
## Pre-create Empty Directories on the Host Machine and Assign Permissions
76+
## Create a container.
77+
sudo docker run -d \
78+
--name jobagent \
79+
-v /apps/ja/logs:/app/logs:rw \
80+
-v /apps/ja/plugins:/app/Plugins:rw \
81+
-v /apps/ja/states:/app/states:rw \
82+
aicrosoft/jobagent:latest
83+
```
84+
85+
### Production Environment with Minimum Privileges
86+
```shell
87+
## Pre-create empty directories on the host machine and assign permissions
6988
sudo mkdir -p /apps/ja/logs /apps/ja/plugins /apps/ja/states
7089
sudo chmod -R 777 /apps/ja
7190
sudo chown -R 65532:65532 /apps/ja
7291

73-
## When creating the container, the plugin directory is empty in the non-DEBUG version.
92+
## Create a container.
7493
sudo docker run -d \
7594
--name jobagent \
7695
-v /apps/ja/logs:/app/logs:rw \

0 commit comments

Comments
 (0)