diff --git a/.gitea/workflows/deploy-workflow.yml b/.gitea/workflows/deploy-workflow.yml new file mode 100644 index 0000000..caa492e --- /dev/null +++ b/.gitea/workflows/deploy-workflow.yml @@ -0,0 +1,33 @@ +name: Gitea Actions Demo +run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀 +on: [push] + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + container: + image: gitea/runner-images:ubuntu-latest + steps: + - run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event." + - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!" + - run: echo "runner arch is ${{ runner.arch }}" + - name: Check out repository code + run: git clone ${{ gitea.server_url }}/${{ gitea.repository }} . + - name: List files + run: ls -la + - name: Stop running containers + run: | + docker compose down || true + - name: Remove old image + run: | + IMAGE_NAME=$(basename "$PWD") + echo "Removing old image: $IMAGE_NAME" + docker images | grep "$IMAGE_NAME" && docker rmi -f $(docker images "$IMAGE_NAME" -q) || echo "No old image found." + - name: Build new image + run: | + docker build -t $(basename "$PWD"):latest . + - name: Start containers + run: | + docker compose up -d + - name: Show container status + run: docker ps \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d77bc20 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +# 使用官方轻量级 Python 基础镜像 +FROM python:3.12-slim + +# 设置工作目录(容器内路径) +WORKDIR /app + +# 将项目文件复制到容器中 +COPY . /app + +# (可选)如果你有 requirements.txt,则先复制并安装依赖 +RUN if [ -f requirements.txt ]; then \ + pip install --no-cache-dir -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/; \ + fi + +# 设置环境变量(防止 Python 缓存文件) +ENV PYTHONUNBUFFERED=1 + +# 启动命令 +CMD ["python", "arlo.py"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..9a67f20 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,7 @@ +version: "3.8" + +services: + app: + image: arlo:latest + container_name: arlo + restart: always