Skip to content

Commit acdca6a

Browse files
Sense Tiovxw
authored andcommitted
容器化变更
增加 Dockerfile 及 github action 配置 自动构建 zh 及 en 两种语言的 arm64 及 aarch64 版本的镜像
1 parent 7aedf14 commit acdca6a

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

.github/workflows/docker.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Package Image
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
env:
9+
# Use docker.io for Docker Hub if empty
10+
REGISTRY: ghcr.io
11+
# github.repository as <account>/<repo>
12+
IMAGE_NAME: ${{ github.repository }}
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
packages: write
20+
# This is used to complete the identity challenge
21+
# with sigstore/fulcio when running outside of PRs.
22+
id-token: write
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v3
27+
28+
# Install the cosign tool except on PR
29+
# https://github.com/sigstore/cosign-installer
30+
- name: Install cosign
31+
if: github.event_name != 'pull_request'
32+
uses: sigstore/cosign-installer@7e0881f8fe90b25e305bbf0309761e9314607e25
33+
with:
34+
cosign-release: 'v1.9.0'
35+
36+
- name: Set up QEMU
37+
uses: docker/setup-qemu-action@v3
38+
39+
# Workaround: https://github.com/docker/build-push-action/issues/461
40+
- name: Setup Docker buildx
41+
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
42+
43+
# Login against a Docker registry except on PR
44+
# https://github.com/docker/login-action
45+
- name: Log into registry ${{ env.REGISTRY }}
46+
if: github.event_name != 'pull_request'
47+
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
48+
with:
49+
registry: ${{ env.REGISTRY }}
50+
username: ${{ github.actor }}
51+
password: ${{ secrets.GITHUB_TOKEN }}
52+
53+
# Build and push Docker image with Buildx (don't push on PR)
54+
# https://github.com/docker/build-push-action
55+
- name: Build and push Docker image - Chinese
56+
id: build-and-push-zh
57+
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
58+
with:
59+
context: .
60+
build-args: LOCALE=zh
61+
push: ${{ github.event_name != 'pull_request' }}
62+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:zh,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:zh-${{ github.ref_name }}
63+
platforms: linux/amd64,linux/arm64
64+
65+
# Build and push Docker image with Buildx (don't push on PR)
66+
# https://github.com/docker/build-push-action
67+
- name: Build and push Docker image - English
68+
id: build-and-push-en
69+
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
70+
with:
71+
context: .
72+
build-args: LOCALE=en
73+
push: ${{ github.event_name != 'pull_request' }}
74+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:en,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:en-${{ github.ref_name }}
75+
platforms: linux/amd64,linux/arm64

Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM alpine as build
2+
3+
ARG LOCALE=zh
4+
5+
ENV RUSTFLAGS="-C target-feature=-crt-static" LOCALE=${LOCALE}
6+
WORKDIR /usr/src/rssbot
7+
COPY . .
8+
RUN apk add --no-cache rustup openssl-dev build-base && rustup-init -y --default-toolchain nightly && source ${HOME}/.cargo/env && cargo build --release
9+
10+
FROM alpine
11+
12+
RUN apk add --no-cache ca-certificates openssl libgcc
13+
ENTRYPOINT [ "/rssbot" ]
14+
15+
COPY --from=build /usr/src/rssbot/target/release/rssbot ./

0 commit comments

Comments
 (0)