Add optional apt/PyPI mirrors and HTTP_PORT

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-05 09:12:41 +03:30
parent a3a99411c6
commit 20c2cc018c
4 changed files with 47 additions and 6 deletions

9
.env.example Normal file
View File

@@ -0,0 +1,9 @@
# Host port published by nginx (maps to container port 80)
HTTP_PORT=80
# Optional Debian apt mirror host (replaces deb.debian.org / security.debian.org)
# APT_MIRROR=mirrors.tuna.tsinghua.edu.cn
# Optional PyPI index URL for pip during image build
# PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
# PIP_TRUSTED_HOST=pypi.tuna.tsinghua.edu.cn

View File

@@ -3,6 +3,26 @@ FROM python:3.14-slim
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ARG APT_MIRROR=
ARG PIP_INDEX_URL=
ARG PIP_TRUSTED_HOST=
# Optional Debian apt mirror (host only, e.g. mirror.example.com)
RUN if [ -n "$APT_MIRROR" ]; then \
if [ -f /etc/apt/sources.list.d/debian.sources ]; then \
sed -i "s|deb.debian.org|${APT_MIRROR}|g; s|security.debian.org|${APT_MIRROR}|g" \
/etc/apt/sources.list.d/debian.sources; \
fi; \
if [ -f /etc/apt/sources.list ]; then \
sed -i "s|deb.debian.org|${APT_MIRROR}|g; s|security.debian.org|${APT_MIRROR}|g" \
/etc/apt/sources.list; \
fi; \
fi
# Optional PyPI mirror (pip reads these env vars)
ENV PIP_INDEX_URL=${PIP_INDEX_URL}
ENV PIP_TRUSTED_HOST=${PIP_TRUSTED_HOST}
WORKDIR /app
# Install dependencies

View File

@@ -23,13 +23,20 @@ The application is fully containerized using Docker, meaning it can be deployed
```bash
cd path/to/product-slip
```
2. Start the application stack using Docker Compose:
2. (Optional) Copy `.env.example` to `.env` and adjust settings:
```bash
cp .env.example .env
```
- `HTTP_PORT` — host port for the app (default `80`)
- `APT_MIRROR` — Debian apt mirror host used during image build
- `PIP_INDEX_URL` / `PIP_TRUSTED_HOST` — PyPI mirror used by pip during image build
3. Start the application stack using Docker Compose:
```bash
docker compose up -d --build
```
3. The server is now running! You can access the application from any device on the same local network:
- If you are on the same machine: Open your browser and go to `http://localhost`
- If you are on a different machine on the same network: Find the host computer's local IP address (e.g., `192.168.1.15`) and go to `http://192.168.1.15`
4. The server is now running! You can access the application from any device on the same local network:
- If you are on the same machine: Open your browser and go to `http://localhost` (or `http://localhost:$HTTP_PORT` if you changed the port)
- If you are on a different machine on the same network: Find the host computer's local IP address (e.g., `192.168.1.15`) and go to `http://192.168.1.15` (add `:$HTTP_PORT` if not using port 80)
### Stopping the Server
To safely stop the application without losing data:

View File

@@ -1,6 +1,11 @@
services:
app:
build: .
build:
context: .
args:
APT_MIRROR: ${APT_MIRROR:-}
PIP_INDEX_URL: ${PIP_INDEX_URL:-}
PIP_TRUSTED_HOST: ${PIP_TRUSTED_HOST:-}
restart: unless-stopped
volumes:
- db_data:/app/data
@@ -15,7 +20,7 @@ services:
image: nginx:alpine
restart: unless-stopped
ports:
- "80:80"
- "${HTTP_PORT:-80}:80"
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
depends_on: