❄️ 使用 Github Action 自动构建 Docker 镜像

This commit is contained in:
xtaodada 2020-08-11 02:10:33 +08:00
parent 58f0627ab6
commit d6aa0595b2
No known key found for this signature in database
GPG Key ID: EE4DC37B55E24736
3 changed files with 41 additions and 7 deletions

35
.github/workflows/docker.yml vendored Normal file
View File

@ -0,0 +1,35 @@
name: Docker Push
on:
push:
branches:
- 'master'
paths-ignore:
- "README.md"
jobs:
buildx:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Dockerhub login
env:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
run: |
echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
- name: Set up Docker Buildx
id: buildx
uses: crazy-max/ghaction-docker-buildx@v1
with:
buildx-version: latest
- name: Build dockerfile (with push)
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
run: |
docker buildx build \
--platform=linux/amd64,linux/arm/v7,linux/arm64 \
--output "type=image,push=true" \
--file ./Dockerfile . \
--tag mrwangzhe/pagermaid_modify:latest

View File

@ -31,13 +31,12 @@ RUN pacman -Syu --needed --noconfirm \
file \ file \
procps-ng procps-ng
RUN sed -e 's;^# \(%wheel.*NOPASSWD.*\);\1;g' -i /etc/sudoers RUN sed -e 's;^# \(%wheel.*NOPASSWD.*\);\1;g' -i /etc/sudoers
RUN useradd pagermaid -u 3333 -r -m -d /pagermaid RUN useradd pagermaid -r -m -d /pagermaid
RUN usermod -aG wheel,users pagermaid RUN usermod -aG wheel,users pagermaid
USER pagermaid USER pagermaid
RUN mkdir /pagermaid/workdir RUN mkdir /pagermaid/workdir
RUN git clone -b master https://github.com/xtaodada/PagerMaid-Modify.git /pagermaid/workdir RUN git clone -b master https://github.com/xtaodada/PagerMaid-Modify.git /pagermaid/workdir
WORKDIR /pagermaid/workdir WORKDIR /pagermaid/workdir
RUN python3 -m virtualenv /pagermaid/venv RUN python3 -m virtualenv venv
RUN source /pagermaid/venv/bin/activate; pip3 install -r requirements.txt RUN source venv/bin/activate; pip3 install -r requirements.txt
CMD ["sh","utils/docker-run.sh"] CMD ["sh","utils/docker-run.sh"]
CMD ["sh","utils/entrypoint.sh"]

View File

@ -55,16 +55,16 @@ access_check() {
build_docker() { build_docker() {
printf "请输入 PagerMaid 容器的名称:" printf "请输入 PagerMaid 容器的名称:"
read -r container_name <&1 read -r container_name <&1
echo "正在构建 Docker 镜像 . . ." echo "正在拉取 Docker 镜像 . . ."
docker rm -f "$container_name" > /dev/null 2>&1 docker rm -f "$container_name" > /dev/null 2>&1
docker build - --force-rm --no-cache -t pagermaid_"$container_name" < Dockerfile.persistant docker pull pagermaid_modify
} }
start_docker() { start_docker() {
echo "正在启动 Docker 容器 . . ." echo "正在启动 Docker 容器 . . ."
echo "在登录后,请按 Ctrl + C 使容器在后台模式下重新启动。" echo "在登录后,请按 Ctrl + C 使容器在后台模式下重新启动。"
sleep 3 sleep 3
docker run -it --restart=always --name="$container_name" --hostname="$container_name" pagermaid_"$container_name" <&1 docker run -it --restart=always --name="$container_name" --hostname="$container_name" pagermaid_modify <&1
echo "" echo ""
echo "Docker 创建完毕。" echo "Docker 创建完毕。"
echo "" echo ""