Skip to content

Commit

Permalink
[CI][#] docker deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhongFuze committed May 23, 2024
1 parent f4fa2a1 commit 2464a69
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/.vscode
/.dockerignore
/Dockerfile
/.git
/.gitignore
/.github
/docs
/log
/data
/justfile
/Makefile
48 changes: 48 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build docker-image

on:
push:
branches:
- main
jobs:
build-image:
if: github.ref_name == 'main' && github.repository == 'ZhongFuze/id_allocation'
runs-on: ubuntu-latest
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Log in to ghcr.io
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Docker BuildX
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-docker-build-${{ hashFiles('**/requirements.txt') }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: "."
push: true
file: Dockerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM python:3.9

LABEL maintainer="Zella Zhong <[email protected]>"

WORKDIR /app

COPY requirements.txt .
RUN pip3 install -r requirements.txt

RUN mkdir -p /app/log
RUN mkdir -p /app/data

COPY src .
COPY run.sh .
COPY supervisord.conf .

ENTRYPOINT ["./run.sh"]
15 changes: 15 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

# use supervisor to start module sbin
supervisord -c /app/supervisord.conf

# use supervisord
if [ $? -eq 0 ]
then
echo "supervisorctl restart all"
supervisorctl -c /app/supervisord.conf restart all

# not use supervisord
else
echo "not use supervisord"
fi
32 changes: 32 additions & 0 deletions supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[unix_http_server]
file=/var/tmp/id_allocation.supervior.sock
chmod=0760
;chmod=0700 ; socket file mode (default 0700)
;chown=nobody:nogroup ; socket file uid:gid owner
;username=user ; default is no username (open server)
;password=123 ; default is no password (open server)

[supervisord]
nodaemon=true
logfile=/var/tmp/id_allocation_supervisord.log
logfile_maxbytes=50MB
logfile_backups=10
loglevel=info
user=root


[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface


[supervisorctl]
serverurl = unix:///var/tmp/id_allocation.supervior.sock

; use nodaemon to start proc
[program:data_server]
command=python3 /app/data_server.py
autostart=true
autorestart=true
stopsignal=KILL
stopasgroup=true
killasgroup=true

0 comments on commit 2464a69

Please sign in to comment.