Skip to content

Commit 909cd07

Browse files
authored
Improved Docker configuration (#47)
* feat: moved advent folder -> puzzles, added some comments * feat(docker): start separation of dev and prod builds, add pytest functionality to backend * feat(docker): added dev/prod to frontend, transition frontend to yarn * fix: remove .vscode folder * fix(makefile): restructured makefile a bit * feat: removed .vscode folder from git * feat(auth): get rudimentary autotesting in place, created clear_database function * feat(test): added all tests for auth/register * fix(puzzle): changed blueprint in routes/puzzle.py
1 parent 3687782 commit 909cd07

28 files changed

+9728
-255
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
config/*.env
1+
config/*.env
2+
.vscode

Makefile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
## COMMON COMMANDS
2+
3+
.PHONY: stop
4+
5+
stop:
6+
docker-compose down
7+
8+
## DEVELOPMENT MODE
9+
10+
.PHONY: build-dev dev destroy-dev restart-dev
11+
12+
build-dev:
13+
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up --build
14+
15+
dev:
16+
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up
17+
18+
destroy-dev:
19+
docker-compose -f docker-compose.yml -f docker-compose.dev.yml down -v
20+
21+
restart-dev: destroy-dev build-dev
22+
23+
## PRODUCTION MODE
24+
25+
.PHONY: build run restart
26+
27+
build:
28+
docker-compose up --build -d
29+
30+
run:
31+
docker-compose up -d
32+
33+
restart:
34+
docker-compose down -v
35+
docker-compose up --build -d
36+
37+
## TESTS
38+
39+
.PHONY: test-backend
40+
41+
test-backend:
42+
docker-compose exec backend pytest .

backend/Dockerfile

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
## BASE BUILD THAT BOTH DEV AND PROD INHERIT FROM
2+
13
# pull official base image
2-
FROM python:3.8.10-slim-buster
4+
FROM python:3.8.10-slim-buster AS base
35

46
# set work directory
57
WORKDIR /backend
@@ -11,10 +13,27 @@ ENV PYTHONUNBUFFERED 1
1113
COPY Pipfile* /backend/
1214

1315
RUN pip install pipenv
14-
RUN pipenv lock -r > requirements.txt
15-
RUN pip uninstall --yes pipenv
16-
RUN pip install -r requirements.txt
1716

1817
EXPOSE 5001
1918

19+
## DEV BUILD
20+
21+
FROM base as dev
22+
23+
RUN pipenv lock --dev --requirements > requirements.txt \
24+
&& pip uninstall --yes pipenv \
25+
&& pip install -r requirements.txt
26+
27+
ENV FLASK_ENV development
28+
2029
CMD [ "python", "app.py" ]
30+
31+
## PROD BUILD
32+
33+
FROM base as prod
34+
35+
RUN pipenv lock --requirements > requirements.txt \
36+
&& pip uninstall --yes pipenv \
37+
&& pip install -r requirements.txt
38+
39+
CMD [ "gunicorn", "--bind", "0.0.0.0:5001", "app:app" ]

backend/Pipfile

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
1-
[[source]]
2-
url = "https://pypi.python.org/simple"
3-
verify_ssl = true
4-
name = "pypi"
5-
6-
[packages]
7-
Flask = "*"
8-
Flask-SQLAlchemy = "*"
9-
Flask-Login = "*"
10-
psycopg2-binary = "*"
11-
email-validator = "*"
12-
argon2-cffi = "*"
13-
flask-jwt-extended = "*"
14-
redis = "*"
15-
flask-cors = "*"
16-
17-
[dev-packages]
18-
19-
[requires]
20-
python_version = "3.8"
1+
[[source]]
2+
url = "https://pypi.python.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[packages]
7+
Flask = "*"
8+
Flask-SQLAlchemy = "*"
9+
Flask-Login = "*"
10+
psycopg2-binary = "*"
11+
email-validator = "*"
12+
argon2-cffi = "*"
13+
flask-jwt-extended = "*"
14+
redis = "*"
15+
flask-cors = "*"
16+
flask-mail = "*"
17+
gunicorn = "*"
18+
19+
[dev-packages]
20+
pytest = "*"
21+
requests = "*"
22+
23+
[requires]
24+
python_version = "3.8"

backend/Pipfile.lock

Lines changed: 118 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/advent/calendar/calendar.py

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)