-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from HChenZi/dev
ci: 支持docker方式运行
- Loading branch information
Showing
3 changed files
with
64 additions
and
1 deletion.
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,40 @@ | ||
name: Docker Hub Release | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Docker | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
||
- name: Generate Tags | ||
uses: docker/metadata-action@v4 | ||
id: metadata | ||
with: | ||
images: | | ||
${{ secrets.DOCKERHUB_USERNAME }}/senkongdao | ||
tags: | | ||
type=raw,value=latest | ||
- name: Build and Publish | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
file: Dockerfile | ||
push: true | ||
tags: ${{ steps.metadata.outputs.tags }} | ||
labels: ${{ steps.metadata.outputs.labels }} |
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,19 @@ | ||
# Build Stage | ||
FROM python:3.9 as build | ||
WORKDIR /usr/app | ||
RUN python -m venv /usr/app/venv | ||
ENV PATH="/usr/app/venv/bin:$PATH" | ||
|
||
COPY requirements.txt . | ||
RUN pip install -r requirements.txt | ||
|
||
# Final Deployment Stage | ||
FROM python:3.9-slim | ||
|
||
WORKDIR /app | ||
COPY --from=build /usr/app/venv . | ||
COPY . . | ||
|
||
ENV PATH="/app/bin:$PATH" | ||
|
||
CMD ["python", "SenKongDao.py"] |
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