-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
131 additions
and
18 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 |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
.github | ||
.mypy_cache | ||
.pytest_cache | ||
data | ||
htmlcov | ||
resources | ||
venv |
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,3 +1,3 @@ | ||
[flake8] | ||
max-line-length = 88 | ||
exclude = .git,__pycache__,__init__.py,.mypy_cache,.pytest_cache,venv | ||
exclude = .git,__pycache__,__init__.py,.mypy_cache,.pytest_cache,venv,resources |
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 |
---|---|---|
|
@@ -15,5 +15,6 @@ venv/ | |
.env | ||
|
||
# Data | ||
resources/ | ||
resources/* | ||
!resources/.gitkeep | ||
*.sqlite |
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,25 @@ | ||
## Setup and Run the Dev Server | ||
|
||
> We recommend using a virtual environment for your project. | ||
> | ||
> You can either use [Conda](https://docs.conda.io/en/latest/) or [Python venv](https://docs.python.org/3/library/venv.html) to create a virtual environment. | ||
- Make sure [Poetry](https://python-poetry.org/) is installed in your environment. | ||
- Create a `.env` file in your project root directory. You can use `env-example` as a template and adjust the variables accordingly. See the Variable section below for more information. | ||
- Install the dependencies: `poetry install`. | ||
- Set up the database: `./scripts/migrations_forward.sh`. | ||
- Set up CTSM repo: `./scripts/setup_ctsm.sh`. | ||
- Run the dev server: `./scripts/run_dev_server.sh`. | ||
|
||
### Variables | ||
|
||
#### Adjustable Variables in `.env`: | ||
|
||
| Variable | Required | Description | Default | Scope | | ||
|:--------------:|:--------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------:|:-------------------------------:|--------| | ||
| CTSM_REPO | No | The CTSM repository to use. | https://github.com/ESCOMP/CTSM/ | API | | ||
| CTSM_TAG | Yes | The CTSM repository tag to use | - | API | | ||
| SQLITE_DB | No | The path to the SQLite file to use. If the file doesn't exist, it will be created at the given path. The default DB will be created in project root. | cases.sqlite | API | | ||
| SQLITE_DB_TEST | No | Same as SQLITE_DB, but for testing. | cases_test.sqlite | API | | ||
| DEBUG | No | Set `DEBUG` state, which is used for adjusting logging level and other debugging purposes. | False | API | | ||
| PORT | No | The port to use for API service in docker | 8000 | Docker | |
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
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
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
Binary file not shown.
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,12 @@ | ||
version: "3.9" | ||
|
||
services: | ||
api: | ||
extends: | ||
file: docker-compose.yaml | ||
service: api | ||
build: | ||
context: . | ||
dockerfile: ./docker/Dockerfile | ||
volumes: | ||
- .:/ctsm-api |
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 @@ | ||
version: "3.9" | ||
|
||
services: | ||
api: | ||
image: ghcr.io/ka7eh/ctsm-api:${VERSION:-latest} | ||
restart: unless-stopped | ||
ports: | ||
- ${PORT:-8000}:8000 | ||
volumes: | ||
- ./resources:/ctsm-api/resources |
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,22 @@ | ||
FROM python:3.10-bullseye | ||
|
||
RUN apt update && apt upgrade -y | ||
|
||
RUN pip install --upgrade pip setuptools | ||
RUN pip install poetry | ||
RUN poetry config virtualenvs.create false | ||
|
||
COPY ./pyproject.toml /ctsm-api/pyproject.toml | ||
COPY ./poetry.lock /ctsm-api/poetry.lock | ||
|
||
WORKDIR /ctsm-api | ||
|
||
RUN poetry install | ||
|
||
COPY docker/entrypoint.sh /ctsm-api/docker/entrypoint.sh | ||
|
||
RUN chmod +x /ctsm-api/docker/entrypoint.sh | ||
|
||
EXPOSE 8000 | ||
|
||
CMD ["/ctsm-api/docker/entrypoint.sh"] |
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 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
cd /ctsm-api | ||
|
||
./scripts/setup_ctsm.sh | ||
./scripts/migrations_forward.sh | ||
|
||
uvicorn app.main:app --reload --host 0.0.0.0 |
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,3 +1,12 @@ | ||
DEBUG=1 | ||
|
||
# DB | ||
SQLITE_DB=cases.sqlite | ||
SQLITE_DB_TEST=cases_test.sqlite | ||
SQLITE_DB_TEST=cases_test.sqlite | ||
|
||
# CTSM | ||
CTSM_REPO=https://github.com/ESCOMP/CTSM/ | ||
CTSM_TAG=ctsm5.1.dev083 | ||
|
||
# Docker | ||
PORT=8000 |
Empty file.
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,7 +1,7 @@ | ||
#! /bin/bash | ||
|
||
set -x | ||
set -e | ||
|
||
export PYTHONPATH=$PWD | ||
export PYTHONPATH=$(dirname $(dirname $(realpath $0))) | ||
|
||
alembic revision --autogenerate -m "${@}" |
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,6 +1,8 @@ | ||
#! /bin/bash | ||
|
||
export PYTHONPATH=$PWD | ||
set -e | ||
|
||
export PYTHONPATH=$(dirname $(dirname $(realpath $0))) | ||
|
||
# Forward migrations to the given revision. Default to `head` if a revision is not passed. | ||
alembic upgrade "${1:-head}" |
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,3 +1,5 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
uvicorn app.main:app --reload |
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,7 +1,7 @@ | ||
#! /bin/bash | ||
|
||
set -x | ||
set -e | ||
|
||
export PYTHONPATH=$PWD | ||
export PYTHONPATH=$(dirname $(dirname $(realpath $0))) | ||
|
||
python app/utils/dependencies.py |