Skip to content

Commit

Permalink
Improved Docker configuration (#47)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
hanyuone authored Jun 12, 2022
1 parent 3687782 commit 909cd07
Show file tree
Hide file tree
Showing 28 changed files with 9,728 additions and 255 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
config/*.env
config/*.env
.vscode
42 changes: 42 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
## COMMON COMMANDS

.PHONY: stop

stop:
docker-compose down

## DEVELOPMENT MODE

.PHONY: build-dev dev destroy-dev restart-dev

build-dev:
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up --build

dev:
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up

destroy-dev:
docker-compose -f docker-compose.yml -f docker-compose.dev.yml down -v

restart-dev: destroy-dev build-dev

## PRODUCTION MODE

.PHONY: build run restart

build:
docker-compose up --build -d

run:
docker-compose up -d

restart:
docker-compose down -v
docker-compose up --build -d

## TESTS

.PHONY: test-backend

test-backend:
docker-compose exec backend pytest .
27 changes: 23 additions & 4 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## BASE BUILD THAT BOTH DEV AND PROD INHERIT FROM

# pull official base image
FROM python:3.8.10-slim-buster
FROM python:3.8.10-slim-buster AS base

# set work directory
WORKDIR /backend
Expand All @@ -11,10 +13,27 @@ ENV PYTHONUNBUFFERED 1
COPY Pipfile* /backend/

RUN pip install pipenv
RUN pipenv lock -r > requirements.txt
RUN pip uninstall --yes pipenv
RUN pip install -r requirements.txt

EXPOSE 5001

## DEV BUILD

FROM base as dev

RUN pipenv lock --dev --requirements > requirements.txt \
&& pip uninstall --yes pipenv \
&& pip install -r requirements.txt

ENV FLASK_ENV development

CMD [ "python", "app.py" ]

## PROD BUILD

FROM base as prod

RUN pipenv lock --requirements > requirements.txt \
&& pip uninstall --yes pipenv \
&& pip install -r requirements.txt

CMD [ "gunicorn", "--bind", "0.0.0.0:5001", "app:app" ]
44 changes: 24 additions & 20 deletions backend/Pipfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"

[packages]
Flask = "*"
Flask-SQLAlchemy = "*"
Flask-Login = "*"
psycopg2-binary = "*"
email-validator = "*"
argon2-cffi = "*"
flask-jwt-extended = "*"
redis = "*"
flask-cors = "*"

[dev-packages]

[requires]
python_version = "3.8"
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"

[packages]
Flask = "*"
Flask-SQLAlchemy = "*"
Flask-Login = "*"
psycopg2-binary = "*"
email-validator = "*"
argon2-cffi = "*"
flask-jwt-extended = "*"
redis = "*"
flask-cors = "*"
flask-mail = "*"
gunicorn = "*"

[dev-packages]
pytest = "*"
requests = "*"

[requires]
python_version = "3.8"
133 changes: 118 additions & 15 deletions backend/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions backend/advent/calendar/calendar.py

This file was deleted.

Loading

0 comments on commit 909cd07

Please sign in to comment.