1
0
Fork 0
mirror of https://github.com/EDeev/web-dev.git synced 2026-10-07 20:49:38 +03:00

Compare commits

...

2 commits

6 changed files with 85 additions and 2 deletions

8
.dockerignore Normal file
View file

@ -0,0 +1,8 @@
.git
.github
docs
*.md
labs
hws
**/__pycache__
ex/db/*.db

35
.github/workflows/docker.yml vendored Normal file
View 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
View 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"]

View file

@ -2,7 +2,8 @@
[Русский](README.md) · **English**
[![CI](https://github.com/EDeev/web-dev/actions/workflows/ci.yml/badge.svg)](https://github.com/EDeev/web-dev/actions/workflows/ci.yml)
[![CI](https://github.com/EDeev/web-dev/actions/workflows/ci.yml/badge.svg)](https://github.com/EDeev/web-dev/actions/workflows/ci.yml)
[![Release](https://img.shields.io/github/v/release/EDeev/web-dev)](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

View file

@ -2,7 +2,8 @@
**Русский** · [English](README.en.md)
[![CI](https://github.com/EDeev/web-dev/actions/workflows/ci.yml/badge.svg)](https://github.com/EDeev/web-dev/actions/workflows/ci.yml)
[![CI](https://github.com/EDeev/web-dev/actions/workflows/ci.yml/badge.svg)](https://github.com/EDeev/web-dev/actions/workflows/ci.yml)
[![Release](https://img.shields.io/github/v/release/EDeev/web-dev)](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
View 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