Using Docker Compose
docker compose --env-file=compose-local.env configdocker compose --env-file=compose-local.env --file=compose-tests.yaml down --remove-orphans && \
docker compose --env-file=compose-local.env --file=compose-tests.yaml build && \
docker compose --env-file=compose-local.env --file=compose-tests.yaml updocker compose --env-file=compose-local.env --file=compose-local.yaml down --remove-orphans && \
docker compose --env-file=compose-local.env --file=compose-local.yaml build && \
docker compose --env-file=compose-local.env --file=compose-local.yaml upUsing pyenv
cd src/
pyenv install 3.11.3
pyenv virtualenv 3.11.3 athena-env
pyenv local athena-env # optional/recommended (auto active env)
pyenv activate athena-env
pip install --upgrade pip
pip install -r requirements.txt -r requirements-dev.txtObs: tested with PostgreSQL v12/15
(Optional) Install lib to generate password:
sudo apt install apache2-utilsGenerating passwords
htpasswd -nb my_user my_passwordsudo su postgres
psql
CREATE DATABASE <your_database_name>;
CREATE USER <your_db_user> WITH PASSWORD '<your_db_password>';
GRANT ALL ON SCHEMA public TO <your_db_user>;
\q
exitDATABASE_CONN_STRING=<your_db_user>:<your_db_password>@<host:port>/<your_database_name>SECRET_KEY=<your_key># recommended generate a key with -openssl rand -hex 32ALGORITHM=HS256 # testedATHENA_ARES_BASE_URL=http://localhost:`#8000` for exampleATHENA_APOLLO_BASE_URL=http://localhost:`#8001` for examplePYTHONBREAKPOINT=ipdb.set_trace # optional/recommended
cd ares/
alembic upgrade head
cd src/
dotenv run uvicorn main:app --reload --port 8000cd apollo/src
dotenv run uvicorn main:app --reload --port 8001Works on free tier!
Required files:
compose-prod.yaml
The variables that you need to set is the same as compose-local.yaml, but we will add this values in GitHub Actions Secrets, because this file contains sensitive credentials.
After we add the secrets on GitHub Actions enviroment(in this project as configured as ATHENA_PROJECT_SECRETS), the deploy.yaml will automatic generate the file compose-prod.yaml.
Basically, what you need to do is create the file compose-prod.yaml locally and create the secret in GitHub Actions from your repository with the name ATHENA_PROJECT_SECRETS and add the content generated by this command:
base64 -w 0 compose-prod.envHow to get project secrets using GitHub Actions
Required options:
- VM Image: Amazon Linux
Add this config in advanced tab to init the instances with this config(or run after).
#!/bin/bash
yum install -y docker
systemctl start docker
systemctl enable dockerAfter run above commands, run the commands bellow.
DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
mkdir -p $DOCKER_CONFIG/cli-plugins
curl -SL https://github.com/docker/compose/releases/download/v2.18.1/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose
chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose
sudo usermod -aG docker ${USER}
sudo reboot(Optional) Install lib to generate password:
sudo apt install apache2-utilsGenerating passwords
htpasswd -nb my_user my_passwordUtils links:
- https://doc.traefik.io/traefik/routing/providers/docker/
- https://doc.traefik.io/traefik/reference/dynamic-configuration/docker/
- https://doc.traefik.io/traefik/user-guides/docker-compose/acme-tls/
{
"folders": [
{
"name": "athena",
"path": "."
},
{
"name": "apollo-devops",
"path": "./apollo"
},
{
"name": "ares-devops",
"path": "./ares"
},
{
"name": "apollo",
"path": "./apollo/src",
},
{
"name": "ares",
"path": "./ares/src"
},
],
"settings": {
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true,
"**/__pycache__": true,
"src": true,
"ares": true,
"apollo": true,
}
}
}