Skip to content
This repository was archived by the owner on Dec 1, 2023. It is now read-only.

Commit 2545136

Browse files
committed
feat: rewrite Dockerfile and CI/CD for supporting two platforms
Since we are supporting both amd64 and arm64, rewrite the CI/CD with cleaner code. Also add conventional metadata onto built images.
1 parent 73a900b commit 2545136

File tree

2 files changed

+46
-10
lines changed

2 files changed

+46
-10
lines changed

.github/workflows/build.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,20 @@ jobs:
2121
run_install: true
2222
- name: Build project
2323
run: pnpm build
24-
- uses: wdzeng/image@v1
24+
- name: Build kelly image
25+
uses: wdzeng/image@v2
2526
with:
2627
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }}
2728
dockerhub-password: ${{ secrets.DOCKERHUB_TOKEN }}
28-
platforms: linux/amd64,linux/arm64
29+
tag-format: kelly-$VERSION
30+
tag-latest: kelly
31+
build-target: kelly
32+
- name: Build regular image
33+
uses: wdzeng/image@v2
34+
with:
35+
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }}
36+
dockerhub-password: ${{ secrets.DOCKERHUB_TOKEN }}
37+
init: false
2938
tag:
3039
name: Add tags to repository
3140
if: ${{ github.event_name == 'push' }}

Dockerfile

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,42 @@
1-
FROM zenika/alpine-chrome:99 as slim
1+
FROM alpine:3.16.1 AS kelly-base
2+
# LABEL org.opencontainers.image.title # set by CI
3+
LABEL org.opencontainers.image.description="Get Shopee coins everyday"
4+
# LABEL org.opencontainers.image.version # set by CI
5+
# LABEL org.opencontainers.image.authors # set by CI
6+
# LABEL org.opencontainers.image.url # set by CI
7+
# LABEL org.opencontainers.image.source # set by CI
8+
# LABEL org.opencontainers.image.created # set by CI
9+
# LABEL org.opencontainers.image.documentation # set by CI
10+
# LABEL org.opencontainers.image.revision # set by CI
11+
LABEL org.opencontainers.image.licenses="MIT"
212

3-
LABEL maintainer="Hyperbola <[email protected]>"
4-
LABEL org.label-schema.name="Shopee Coins Bot"
5-
LABEL org.label-schema.description="Get shopee coins everyday."
6-
LABEL org.label-schema.url="https://github.com/wdzeng/shopee-coins-bot"
713

14+
# Install required packages and add a non-root user
815
USER root
9-
RUN apk add --no-cache chromium-chromedriver nodejs tini
16+
RUN apk add --no-cache chromium chromium-chromedriver nodejs tini \
17+
&& adduser -u 1000 -H -D bot
18+
ENV IMAGE_VARIANT=kelly
19+
ENV TZ=Asia/Taipei
20+
ENV CHROME_BIN=/usr/bin/chromium-browser
21+
ENV CHROME_PATH=/usr/lib/chromium/
22+
23+
24+
# The regular image that contains CJK font
25+
FROM kelly-base AS base
26+
USER root
27+
RUN apk add --no-cache font-noto-cjk
28+
ENV IMAGE_VARIANT=regular
29+
30+
31+
FROM kelly-base as kelly
32+
USER bot
1033
COPY dist /app
34+
WORKDIR /app
35+
ENTRYPOINT [ "tini", "--", "node", "index.js" ]
1136

12-
USER chrome
13-
ENV TZ="Asia/Taipei"
37+
38+
FROM base
39+
USER bot
40+
COPY dist /app
1441
WORKDIR /app
1542
ENTRYPOINT [ "tini", "--", "node", "index.js" ]

0 commit comments

Comments
 (0)