-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |