ci: add Dockerfile
All checks were successful
Docker Build / docker build and publish (push) Successful in 1m14s

This commit is contained in:
xtaodada 2024-05-16 20:46:58 +08:00
parent ea26dddbde
commit 3de12c1de7
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
3 changed files with 63 additions and 2 deletions

View File

@ -0,0 +1,50 @@
name: "Docker Build"
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
workflow_dispatch: ~
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
name: docker build and publish
env:
DOCKER_BUILDKIT: 1
DOCKER_CLI_EXPERIMENTAL: enabled
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKERHUB_REPOSITORY: ${{ vars.DOCKER_REPO }}
DOCKER_TAG: 'latest'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Setup Docker Buildx
uses: crazy-max/ghaction-docker-buildx@v3
- name: Buildx cache
uses: actions/cache@v2
id: buildx-cache
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx
- name: Build
run: |
docker buildx build \
--cache-from "type=local,src=/tmp/.buildx-cache" \
--cache-to "type=local,dest=/tmp/.buildx-cache" \
--output "type=image,push=true" \
--platform "linux/amd64" \
--tag "${DOCKERHUB_REPOSITORY}:${DOCKER_TAG}" \
-f Dockerfile \
.

11
Dockerfile Normal file
View File

@ -0,0 +1,11 @@
FROM python:3.12-slim
LABEL authors="xtaodada"
WORKDIR /usr/app
COPY requirements.txt .
RUN /bin/sh -c set -eux; apt-get update; apt-get install -y --no-install-recommends git ; rm -rf /var/lib/apt/lists/* # buildkit
RUN pip install -r requirements.txt
COPY . .
CMD [ "python", "main.py" ]

View File

@ -11,6 +11,6 @@ aiofiles==23.2.1
jinja2==3.1.3 jinja2==3.1.3
beautifulsoup4 beautifulsoup4
lxml lxml
tgcrypto PyroTgCrypto==1.2.6a0
pyrogram git+https://github.com/TeamPGM/pyrogram
urlextract urlextract