Add optional apt/PyPI mirrors and HTTP_PORT
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
9
.env.example
Normal file
9
.env.example
Normal 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
|
||||||
20
Dockerfile
20
Dockerfile
@@ -3,6 +3,26 @@ FROM python:3.14-slim
|
|||||||
ENV PYTHONDONTWRITEBYTECODE=1
|
ENV PYTHONDONTWRITEBYTECODE=1
|
||||||
ENV PYTHONUNBUFFERED=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
|
WORKDIR /app
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
|
|||||||
15
README.md
15
README.md
@@ -23,13 +23,20 @@ The application is fully containerized using Docker, meaning it can be deployed
|
|||||||
```bash
|
```bash
|
||||||
cd path/to/product-slip
|
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
|
```bash
|
||||||
docker compose up -d --build
|
docker compose up -d --build
|
||||||
```
|
```
|
||||||
3. The server is now running! You can access the application from any device on the same local network:
|
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`
|
- 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`
|
- 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
|
### Stopping the Server
|
||||||
To safely stop the application without losing data:
|
To safely stop the application without losing data:
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
build: .
|
build:
|
||||||
|
context: .
|
||||||
|
args:
|
||||||
|
APT_MIRROR: ${APT_MIRROR:-}
|
||||||
|
PIP_INDEX_URL: ${PIP_INDEX_URL:-}
|
||||||
|
PIP_TRUSTED_HOST: ${PIP_TRUSTED_HOST:-}
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
volumes:
|
volumes:
|
||||||
- db_data:/app/data
|
- db_data:/app/data
|
||||||
@@ -15,7 +20,7 @@ services:
|
|||||||
image: nginx:alpine
|
image: nginx:alpine
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "${HTTP_PORT:-80}:80"
|
||||||
volumes:
|
volumes:
|
||||||
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|||||||
Reference in New Issue
Block a user