-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update frontend dependencies. Update eslint and tsconfig * update backend dependencies * add ruff and mypy * fix some ruff issues (sorting) * fix ruff issues * update config * fix mypy errors * fix mypy issues * fix frontend lint issues * fix security issue with fast-api-sso * add pre-commit config file * remove facebook sso * remove deprecated Grid component. Use Grid2 instead * fix tests by changing testing api url * update node and mongodb versions in tests workflow * make black use pyproject.toml in github actions * Add config to black * change working dir for python lint * refactor docker-compose setup. Update traefik to v3.2 * add docker watch for frontend container * add node_modules ignore to docker watch * refactor config to use root level .env file * update docker doc in README
- Loading branch information
1 parent
12461de
commit 44fdbde
Showing
47 changed files
with
3,249 additions
and
5,376 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,44 @@ | ||
### Domain name for the app | ||
DOMAIN=localhost | ||
|
||
### Environment: development, test, production | ||
ENVIRONMENT=development | ||
|
||
### Project name and stack name | ||
PROJECT_NAME=farm-docker | ||
STACK_NAME=farm-docker | ||
|
||
TRAEFIK_PUBLIC_NETWORK=traefik-public | ||
TRAEFIK_TAG=farm-docker | ||
TRAEFIK_PUBLIC_TAG=traefik-public | ||
TRAEFIK_PUBLIC_NETWORK_IS_EXTERNAL=false | ||
### Email adress used by traefik to obtain Let's Encrypt certificates | ||
TRAEFIK_TLS_EMAIL=[email protected] | ||
|
||
### Docker package registry and images | ||
DOCKER_IMAGE_BACKEND=farmd-backend | ||
DOCKER_IMAGE_FRONTEND=farmd-frontend | ||
DOCKER_PACKAGE_REPOSITORY=ghcr.io/jonasrenault | ||
|
||
# Backend | ||
BACKEND_CORS_ORIGINS=["http://localhost", "http://localhost:5173", "http://localhost:3000", "http://localhost:8080", "https://localhost", "https://localhost:5173", "https://localhost:3000", "https://localhost:8080", "http://dev.farm-docker.com", "https://stag.farm-docker.com", "https://farm-docker.com"] | ||
PROJECT_NAME=farm-docker | ||
### Backend variables | ||
BACKEND_CORS_ORIGINS=["http://localhost", "http://localhost:5173", "https://localhost", "https://localhost:5173"] | ||
SECRET_KEY=98153798f1616ba9e65c2cbcdb3fd3e3a6297b2002f6936b72823fd21ce609d9 | ||
FIRST_SUPERUSER=[email protected] | ||
FIRST_SUPERUSER_PASSWORD=admin | ||
|
||
### SSO variables | ||
GOOGLE_CLIENT_ID= | ||
GOOGLE_CLIENT_SECRET= | ||
FACEBOOK_CLIENT_ID= | ||
FACEBOOK_CLIENT_SECRET= | ||
# HOSTNAME used to build google redirect uri. Should point to backend | ||
SSO_CALLBACK_HOSTNAME=http://localhost | ||
# Callback URL we redirect to after google login. Should point to frontend/sso-login-callback | ||
SSO_LOGIN_CALLBACK_URL=http://localhost/sso-login-callback | ||
|
||
# Frontend | ||
### HOSTNAME used to build google redirect uri. Should point to backend | ||
SSO_CALLBACK_HOSTNAME=http://localhost:8000 | ||
### Callback URL we redirect to after google login. Should point to frontend/sso-login-callback | ||
SSO_LOGIN_CALLBACK_URL=http://localhost:5173/sso-login-callback | ||
|
||
### Frontend variables | ||
VITE_BACKEND_API_URL=http://localhost/api/v1/ | ||
VITE_PWD_SIGNUP_ENABLED=true | ||
VITE_GA_TRACKING_ID= | ||
|
||
# MongoDB | ||
MONGO_HOST=db | ||
### MongoDB variables | ||
MONGO_HOST=localhost | ||
MONGO_DB=farmd | ||
MONGO_PORT=27017 | ||
MONGO_USER=mongodbadmin | ||
MONGO_PASSWORD=wpnimdabdognom | ||
# uncomment following lines to set mongodb user and password | ||
# MONGO_USER=mongodbadmin | ||
# MONGO_PASSWORD=wpnimdabdognom |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,9 +13,9 @@ on: | |
- main | ||
|
||
env: # environment variables (available in any part of the action) | ||
NODE_VERSION: 20 | ||
PYTHON_VERSION: 3.11 | ||
MONGODB_VERSION: 6.0 | ||
NODE_VERSION: 21 | ||
PYTHON_VERSION: 3.12 | ||
MONGODB_VERSION: 8.0 | ||
|
||
jobs: | ||
run-js-linters: | ||
|
@@ -33,7 +33,7 @@ jobs: | |
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ env.NODE_VERSION }} | ||
cache: 'npm' | ||
cache: "npm" | ||
cache-dependency-path: frontend/package-lock.json | ||
|
||
- name: Install Node.js dependencies | ||
|
@@ -55,6 +55,8 @@ jobs: | |
|
||
- name: Run black | ||
uses: psf/black@stable | ||
with: | ||
options: "--config backend/pyproject.toml" | ||
|
||
test-backend: | ||
name: Run backend unit tests | ||
|
@@ -75,7 +77,7 @@ jobs: | |
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
cache: 'poetry' | ||
cache: "poetry" | ||
|
||
- name: Start MongoDB | ||
uses: supercharge/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,40 @@ | ||
default_language_version: | ||
python: python3.12 | ||
|
||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.3.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-yaml | ||
- id: debug-statements | ||
- repo: https://github.com/psf/black | ||
rev: 23.10.1 | ||
hooks: | ||
- id: black | ||
# It is recommended to specify the latest version of Python | ||
# supported by your project here, or alternatively use | ||
# pre-commit's default_language_version, see | ||
# https://pre-commit.com/#top_level-default_language_version | ||
language_version: python3.11 | ||
- repo: https://github.com/python-poetry/poetry | ||
rev: '1.5.1' | ||
hooks: | ||
- id: poetry-check | ||
args: ["--directory", "backend"] | ||
- id: poetry-lock | ||
args: ["--directory", "backend"] | ||
- id: poetry-export | ||
args: ["-f", "requirements.txt", "-o", "backend/requirements.txt", "--directory", "backend", "--with", "dev"] | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.6.0 | ||
hooks: | ||
- id: check-added-large-files | ||
- id: check-toml | ||
- id: check-yaml | ||
args: [--allow-multiple-documents] | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
|
||
- repo: https://github.com/psf/black | ||
rev: 24.8.0 | ||
hooks: | ||
- id: black | ||
name: black | ||
args: | ||
- "--config" | ||
- "./backend/pyproject.toml" | ||
|
||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.6.9 | ||
hooks: | ||
# Run the linter. | ||
- id: ruff | ||
# Run the formatter. | ||
- id: ruff-format | ||
|
||
- repo: https://github.com/pre-commit/mirrors-mypy | ||
rev: v1.11.2 | ||
hooks: | ||
- id: mypy | ||
name: mypy | ||
args: | ||
- "--config" | ||
- "./backend/pyproject.toml" | ||
- "--ignore-missing-imports" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Python | ||
__pycache__ | ||
app.egg-info | ||
*.pyc | ||
.mypy_cache | ||
.pytest_cache | ||
.ruff_cache | ||
.coverage | ||
htmlcov | ||
.venv |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
FROM tiangolo/uvicorn-gunicorn-fastapi:latest | ||
FROM python:3.12-slim | ||
|
||
ENV PYTHONUNBUFFERED=true | ||
|
||
WORKDIR /app | ||
|
||
ENV POETRY_HOME=/opt/poetry | ||
# ENV POETRY_VIRTUALENVS_IN_PROJECT=true | ||
ENV PATH="$POETRY_HOME/bin:$PATH" | ||
RUN curl -sSL https://install.python-poetry.org | python3 - | ||
RUN poetry config virtualenvs.create false | ||
# Copy poetry.lock* in case it doesn't exist in the repo | ||
COPY ./pyproject.toml ./poetry.lock* /app/ | ||
### install poetry | ||
RUN pip install poetry && poetry config virtualenvs.in-project true | ||
|
||
### install dependencies and project | ||
ADD pyproject.toml README.md ./ | ||
ADD app /app/app | ||
RUN poetry install --no-interaction --no-ansi | ||
|
||
# Allow installing dev dependencies to run tests | ||
ARG INSTALL_DEV=false | ||
RUN bash -c "if [ $INSTALL_DEV == 'true' ] ; then poetry install --no-root ; else poetry install --no-root --no-dev ; fi" | ||
### add executables to path | ||
ENV PATH="/app/.venv/bin:$PATH" | ||
|
||
COPY . /app | ||
ENV PYTHONPATH=/app | ||
### default cmd: run fastapi with 4 workers | ||
CMD ["fastapi", "run", "--workers", "4", "app/main.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.