Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker - install fittrackee in a virtualenv #374

Merged
merged 1 commit into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ WORKDIR /usr/src/app
COPY . /usr/src/app

# install requirements
ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN pip install --upgrade pip
RUN pip install poetry
RUN poetry config virtualenvs.create false
RUN poetry install --no-interaction --quiet

# create uploads folder
CMD mkdir /usr/src/app/uploads
RUN . $VIRTUAL_ENV/bin/activate && poetry install --no-interaction --quiet

# run fittrackee server
CMD flask run --with-threads -h 0.0.0.0
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ clean-install: clean

## Docker commands for evaluation purposes
docker-bandit:
docker-compose -f docker-compose-dev.yml exec fittrackee $(DOCKER_BANDIT) -r fittrackee -c pyproject.toml
docker-compose -f docker-compose-dev.yml exec fittrackee bandit -r fittrackee -c pyproject.toml

docker-build:
docker-compose -f docker-compose-dev.yml build fittrackee
Expand All @@ -56,7 +56,7 @@ docker-build-client:
docker-check-all: docker-bandit docker-lint-all docker-type-check docker-test-client docker-test-python

docker-downgrade-db:
docker-compose -f docker-compose-dev.yml exec fittrackee $(DOCKER_FLASK) db downgrade --directory $(DOCKER_MIGRATIONS)
docker-compose -f docker-compose-dev.yml exec fittrackee flask db downgrade --directory $(DOCKER_MIGRATIONS)

docker-init: docker-run docker-init-db docker-restart docker-run-workers

Expand All @@ -76,7 +76,7 @@ docker-logs:
docker-compose -f docker-compose-dev.yml logs --follow

docker-migrate-db:
docker-compose -f docker-compose-dev.yml exec fittrackee $(DOCKER_FLASK) db migrate --directory $(DOCKER_MIGRATIONS)
docker-compose -f docker-compose-dev.yml exec fittrackee flask db migrate --directory $(DOCKER_MIGRATIONS)

docker-rebuild:
docker-compose -f docker-compose-dev.yml build --no-cache
Expand All @@ -86,7 +86,7 @@ docker-restart:
docker-compose -f docker-compose-dev.yml exec -d fittrackee docker/run-workers.sh

docker-revision:
docker-compose -f docker-compose-dev.yml exec fittrackee $(DOCKER_FLASK) db revision --directory $(DOCKER_MIGRATIONS) --message $(MIGRATION_MESSAGE)
docker-compose -f docker-compose-dev.yml exec fittrackee flask db revision --directory $(DOCKER_MIGRATIONS) --message $(MIGRATION_MESSAGE)

docker-run-all: docker-run docker-run-workers

Expand Down Expand Up @@ -123,13 +123,13 @@ docker-test-python: docker-run

docker-type-check:
echo 'Running mypy in docker...'
docker-compose -f docker-compose-dev.yml exec fittrackee $(DOCKER_MYPY) fittrackee
docker-compose -f docker-compose-dev.yml exec fittrackee mypy fittrackee

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

docker-upgrade-db:
docker-compose -f docker-compose-dev.yml exec fittrackee $(DOCKER_FTCLI) db upgrade
docker-compose -f docker-compose-dev.yml exec fittrackee ftcli db upgrade

downgrade-db:
$(FLASK) db downgrade --directory $(MIGRATIONS)
Expand Down
4 changes: 0 additions & 4 deletions Makefile.config
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ FTCLI = $(VENV)/bin/ftcli
# Docker env
export DOCKER_APP_DIR = /usr/src/app
export DOCKER_MIGRATIONS = $(DOCKER_APP_DIR)/fittrackee/migrations
export DOCKER_FLASK = /usr/local/bin/flask
export DOCKER_FTCLI = /usr/local/bin/ftcli
export DOCKER_BANDIT = /usr/local/bin/bandit
export DOCKER_MYPY = /usr/local/bin/mypy

# Node env
NODE_MODULES = $(PWD)/fittrackee_client/node_modules
Expand Down
1 change: 0 additions & 1 deletion docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ services:
- mail
volumes:
- .:/usr/src/app
- ./data/workouts:/usr/src/app/workouts
- ./data/uploads:/usr/src/app/uploads
networks:
- fittrackee-net
Expand Down
4 changes: 3 additions & 1 deletion docker/lint-python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ cd /usr/src/app
source .env

mypy fittrackee
pytest --flake8 --isort --black -m "flake8 or isort or black" fittrackee e2e --ignore=fittrackee/migrations
pytest --isort --black -m "isort or black" fittrackee e2e --ignore=fittrackee/migrations
echo 'Running flake8...'
flake8 fittrackee e2e