Skip to content

Commit

Permalink
alpine image -> 300M
Browse files Browse the repository at this point in the history
  • Loading branch information
aogg authored Apr 13, 2024
1 parent a3e3c62 commit 319f937
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 19 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/alpine.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: 构建和提交docker

on:
push:
branches: [main]
paths:
- "./**"
- ".github/workflows/alpine.yml"
- "!**.md"

jobs:

# 并发构建
setup-build-publish-v3:
runs-on: ubuntu-latest
name: 构建和推送docker镜像v3
steps:

- name: 更新代码
# 使用action库 actions/checkout获取源码
uses: actions/checkout@v3


-
name: 登录 Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}

# ########## 构建 ###########################




# - name: 构建与推送
# uses: docker/build-push-action@v1.1.0
# with:
# # Username used to log in to a Docker registry. If not set then no login will occur
# username: ${{ secrets.USERNAME }}
# # Password or personal access token used to log in to a Docker registry. If not set then no login will occur
# password: ${{ secrets.PASSWORD }}
# # Docker repository to tag the image with
# repository: adockero/electerm-web
# # Comma-delimited list of tags. These will be added to the registry/repository to form the image's tags
# # tags: debug
# # Path to the Dockerfile (Default is '{path}/Dockerfile')
# path: ./
# dockerfile: Dockerfile
# # Always attempt to pull a newer version of the image
# always_pull: true
# # 构建参数
# # build_args: GIT_BRANCH=master
# # Adds labels with git repository information to the built image
# add_git_labels: true

- name: 构建与推送--alpine
uses: docker/build-push-action@v3
with:
# Comma-delimited list of tags. These will be added to the registry/repository to form the image's tags
tags: ${{ secrets.USERNAME }}/electerm-web
# Path to the Dockerfile (Default is '{path}/Dockerfile')
context: ./
file: "./Dockerfile.alpine"
# Always attempt to pull a newer version of the image
pull: true
push: true
# 构建参数
# build-args: |
# FROM_ARG=node:11-alpine
# APK_ARG=rsync
# Adds labels with git repository information to the built image
labels: true

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.history

# Logs
logs
*.log
Expand Down
40 changes: 21 additions & 19 deletions Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,28 @@ LABEL url="https://github.com/electerm/electerm-web-docker"
LABEL vendor="electerm"
LABEL version="2.38.65"

# Install the build tools necessary for node-gyp
RUN apk update && apk add --no-cache --virtual /root/.gyp git python3 make g++ \
&& addgroup -S electerm \
&& adduser -S electerm -G electerm -h /home/electerm -s /bin/bash \
&& chown -R electerm:electerm /home/electerm && chmod 755 /home/electerm
USER electerm
# RUN chown -R electerm:electerm /home/electerm
WORKDIR /app
RUN chown -R electerm:electerm /app \
&& git clone --depth 1 https://github.com/electerm/electerm-web.git
WORKDIR /app/electerm-web
RUN npm un @playwright/test chai playwright \
&& npm i \
&& npm run build \
&& cp .sample.env .env \
&& npm prune --production \
&& npm cache clean --force

USER root
RUN apk del /root/.gyp

RUN addgroup -S electerm \
&& adduser -S electerm -G electerm -h /home/electerm -s /bin/bash \
&& chown -R electerm:electerm /home/electerm && chmod 755 /home/electerm \
&& mkdir -p /app && chown -R electerm:electerm /app


# Install the build tools necessary for node-gyp
RUN apk update && apk add --no-cache --virtual /root/.gyp python3 git make g++ \
&& cd /app \
&& git clone --depth 1 https://github.com/electerm/electerm-web.git \
&& cd electerm-web \
&& npm un @playwright/test chai playwright \
&& npm i \
&& npm run build \
&& cp .sample.env .env \
&& npm prune --production \
&& npm cache clean --force \
&& apk del /root/.gyp \
&& chown -R electerm:electerm /app/electerm-web


USER electerm
WORKDIR /app/electerm-web
Expand Down

0 comments on commit 319f937

Please sign in to comment.