Skip to content

Commit

Permalink
chore: Update Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Porter committed Jul 6, 2024
1 parent 889d0b8 commit 40d2c38
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 使用官方Python运行时作为父镜像
FROM python:3.10-slim
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# 设置工作目录
WORKDIR /app
# 将当前目录内容复制到位于/app中的容器中docker build -t myapp .
Expand Down
54 changes: 38 additions & 16 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,47 @@ QSyncBackend is a simple backend written in Python for syncing files between two
4. Run the backend using `gunicorn -w 4 -b 127.0.0.1:8080 app:app`

## Run from Docker
1. Modify the `.env` file to set your MySQL database credentials:
1. Set your mysql, and create user and database.

```bash
DB_USER=your_username
DB_PASSWORD=your_password
DB_NAME=your_database_name
DB_HOST=your_database_host
SECRET_KEY=your_secret_key_here
NEED_CAPTCHA=True
```
2. Run the backend using Docker with the following command, replacing the placeholders with your actual values:

2. Run
```bash
docker run -d -p 8099:8080 --env-file .env ghcr.io/alexander-porter/qsyncbackend:main
docker run -d -p 8099:8080 -e DB_USER=your_username -e DB_PASSWORD=your_password -e DB_NAME=your_database_name -e DB_HOST=your_database_host -e SECRET_KEY=your_secret_key_here -e NEED_CAPTCHA=True ghcr.io/alexander-porter/qsyncbackend:main
```

## Run from Docker Compose
1. Clone the repository
2. Run
```bash
docker-compose up -d
```
1. Set the environment variables in a `.env` file
2. Docker-Compose
```yaml
version: '3.8'
services:
mysql:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: "${DB_PASSWORD}"
MYSQL_DATABASE: "${DB_NAME}"
volumes:
- mysql-data:/var/lib/mysql
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-p${DB_PASSWORD}"]
interval: 30s
timeout: 30s
retries: 5
web:
image: ghcr.io/alexander-porter/qsyncbackend:main
ports:
- "8099:8080"
environment:
SECRET_KEY: "${SECRET_KEY}"
DB_PASSWORD: "${DB_PASSWORD}"
DB_NAME: "${DB_NAME}"
depends_on:
mysql:
condition: service_healthy
volumes:
mysql-data:
```

0 comments on commit 40d2c38

Please sign in to comment.