mirror of
https://github.com/EDeev/web-dev.git
synced 2026-10-07 20:49:38 +03:00
Compare commits
2 commits
9a23fc52e0
...
b1c8a8e1ee
| Author | SHA1 | Date | |
|---|---|---|---|
| b1c8a8e1ee | |||
| a9498c83ce |
6 changed files with 85 additions and 2 deletions
8
.dockerignore
Normal file
8
.dockerignore
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
.git
|
||||
.github
|
||||
docs
|
||||
*.md
|
||||
labs
|
||||
hws
|
||||
**/__pycache__
|
||||
ex/db/*.db
|
||||
35
.github/workflows/docker.yml
vendored
Normal file
35
.github/workflows/docker.yml
vendored
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
name: Docker
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: ["v*"]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
image:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: docker/setup-buildx-action@v3
|
||||
- uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ghcr.io/edeev/web-dev
|
||||
tags: |
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=raw,value=latest
|
||||
- uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
13
Dockerfile
Normal file
13
Dockerfile
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# Экзаменационное приложение курса (ex/, сайт ex-web): Flask + SQLite за gunicorn
|
||||
FROM python:3.12-slim
|
||||
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
|
||||
WORKDIR /app
|
||||
COPY ex/requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt gunicorn
|
||||
COPY ex/ .
|
||||
# копия скриптов базы — том /app/db при первом запуске пустой
|
||||
RUN cp -r db /opt/db-seed
|
||||
COPY docker/entrypoint.sh /entrypoint.sh
|
||||
EXPOSE 8000
|
||||
VOLUME ["/app/db", "/app/app/static/uploads"]
|
||||
ENTRYPOINT ["sh", "/entrypoint.sh"]
|
||||
12
README.en.md
12
README.en.md
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
[Русский](README.md) · **English**
|
||||
|
||||
[](https://github.com/EDeev/web-dev/actions/workflows/ci.yml)
|
||||
[](https://github.com/EDeev/web-dev/actions/workflows/ci.yml)
|
||||
[](https://github.com/EDeev/web-dev/releases)
|
||||
|
||||
Labs, homework and the exam project for the "Web Development" course at Moscow Polytechnic University:
|
||||
six Flask apps, 37 Python exercises with tests, and an online library.
|
||||
|
|
@ -39,6 +40,15 @@ python run.py
|
|||
`SECRET_KEY` and `FLASK_DEBUG` come from environment variables. Homework tests:
|
||||
`cd hws/hw-1 && pytest test.py`.
|
||||
|
||||
**Docker:** the exam app `ex/` as a prebuilt image:
|
||||
|
||||
```bash
|
||||
docker run -d -p 8000:8000 -e SECRET_KEY=change-me -v webdev-db:/app/db -v webdev-uploads:/app/app/static/uploads ghcr.io/edeev/web-dev
|
||||
docker logs <container> # on first start: logins and passwords of the test users
|
||||
```
|
||||
|
||||
(same as `git.deev.su/edeev/web-dev`), then open http://localhost:8000.
|
||||
|
||||
## License
|
||||
|
||||
Coursework (Web Development, Moscow Polytechnic University, 2025/26). The code is open for study; there
|
||||
|
|
|
|||
12
README.md
12
README.md
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
**Русский** · [English](README.en.md)
|
||||
|
||||
[](https://github.com/EDeev/web-dev/actions/workflows/ci.yml)
|
||||
[](https://github.com/EDeev/web-dev/actions/workflows/ci.yml)
|
||||
[](https://github.com/EDeev/web-dev/releases)
|
||||
|
||||
Лабораторные, домашние задания и экзаменационный проект по курсу «Веб-разработка» в Московском
|
||||
Политехе: шесть Flask-приложений, 37 задач на Python с тестами и электронная библиотека.
|
||||
|
|
@ -39,6 +40,15 @@ python run.py
|
|||
`SECRET_KEY` и `FLASK_DEBUG` задаются переменными окружения. Тесты домашних заданий:
|
||||
`cd hws/hw-1 && pytest test.py`.
|
||||
|
||||
**Docker:** экзаменационное приложение `ex/` — готовый образ:
|
||||
|
||||
```bash
|
||||
docker run -d -p 8000:8000 -e SECRET_KEY=смените-меня -v webdev-db:/app/db -v webdev-uploads:/app/app/static/uploads ghcr.io/edeev/web-dev
|
||||
docker logs <контейнер> # при первом запуске — логины и пароли тестовых пользователей
|
||||
```
|
||||
|
||||
(то же — `git.deev.su/edeev/web-dev`), сайт на http://localhost:8000.
|
||||
|
||||
## Лицензия
|
||||
|
||||
Учебный проект (Веб-разработка, Московский Политех, 2025/26). Код открыт для изучения, отдельной
|
||||
|
|
|
|||
7
docker/entrypoint.sh
Normal file
7
docker/entrypoint.sh
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
# Первый запуск: база с ролями и тестовыми пользователями (пароли — из SEED_*_PASSWORD или случайные, в лог)
|
||||
set -e
|
||||
cp -n /opt/db-seed/* /app/db/ 2>/dev/null || true
|
||||
[ -f /app/db/library.db ] || python db/db_seed.py
|
||||
mkdir -p /app/app/static/uploads
|
||||
exec gunicorn --workers 2 --bind 0.0.0.0:8000 app:app
|
||||
Loading…
Add table
Reference in a new issue