Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom JEANNESSON committed Jan 2, 2024
1 parent 93a8a8c commit 50570e2
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 5 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jobs:
- name: build
run: |
make build
docker ps -a
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
Expand All @@ -30,7 +29,7 @@ jobs:

- name: Tag Docker image
run: |
docker ps -a
docker image ls
echo "$(echo ${{ github.sha }})" > version.txt
docker tag local-image:tag ghcr.io/${{ github.repository }}/local-image:$(cat version.txt)
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,5 @@ cython_debug/
### Custom
requirements.txt
full-requirements.txt
.vscode
.vscode
provisionEB
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,8 @@ coverage-open:
litestream:
set -a && . ./backend/.envs/.development/.litestream && set +a && litestream replicate --config backend/docker/compose/production/litestream/config.yml

setup-prod:
./backend/docker/setup-prod.sh

build-prod: setup-prod
docker compose -f backend/docker/production.yml build
20 changes: 20 additions & 0 deletions backend/.envs/.production/.django
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# General secrets
# ------------------------------------------------------------------------------
USE_DOCKER="yes"
IPYTHONDIR="/app/.ipython"

# Redis
# ------------------------------------------------------------------------------
REDIS_URL="redis://redis:6379/0"

# Django
# ------------------------------------------------------------------------------
SECRET_KEY="" # TODO : Generate random password
DJANGO_DEBUG=False
IS_LOCAL=False

# Flower
# ------------------------------------------------------------------------------
CELERY_FLOWER_USER="" # TODO : Generate random password
CELERY_FLOWER_PASSWORD="" # TODO : Generate random password
DB_ENGINE="POSTGRES"
4 changes: 4 additions & 0 deletions backend/.envs/.production/.litestream
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DB_SETUP=litestream
LITESTREAM_ACCESS_KEY_ID="" # TODO : Generate random password
LITESTREAM_SECRET_ACCESS_KEY="" # TODO : Generate random password
S3_BUCKET_PATH="" # TODO : Create s3 bucket
2 changes: 0 additions & 2 deletions backend/docker/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ services:

celeryworker:
<<: *django
image: napse_dtk_prod_celeryworker
container_name: napse_dtk_prod_celeryworker
depends_on:
- redis
Expand All @@ -36,7 +35,6 @@ services:

celerybeat:
<<: *django
image: napse_dtk_prod_celerybeat
container_name: napse_dtk_prod_celerybeat
depends_on:
- redis
Expand Down
64 changes: 64 additions & 0 deletions backend/docker/setup-prod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
mkdir -p provisionEB
touch provisionEB/Dockerrun.aws.json
touch provisionEB/config.json

cp backend/docker/production.yml provisionEB/docker-compose.yml

cat << EOF > provisionEB/Dockerrun.aws.json
{
"AWSEBDockerrunVersion": "3",
"Authentication": {
"bucket": "$AWS_BUCKET_NAME_BACKEND",
"key": "config.json"
}
}
EOF

cat << EOF > provisionEB/config.json
{
"auths": {
"ghcr.io": {
"auth": "$NAPSE_SECRET_DEPLOYMENT_TOKEN_AWS"
}
}
}
EOF
mkdir -p backend/.envs
mkdir -p backend/.envs/.production


cat << EOF > backend/.envs/.production/.django
# General secrets
# ------------------------------------------------------------------------------
USE_DOCKER="yes"
IPYTHONDIR="/app/.ipython"
# Redis
# ------------------------------------------------------------------------------
REDIS_URL="redis://redis:6379/0"
# Django
# ------------------------------------------------------------------------------
SECRET_KEY="" # TODO : Generate random password
DJANGO_DEBUG=False
IS_LOCAL=False
# Flower
# ------------------------------------------------------------------------------
CELERY_FLOWER_USER="" # TODO : Generate random password
CELERY_FLOWER_PASSWORD="" # TODO : Generate random password
DB_ENGINE="POSTGRES"
EOF

cat << EOF > backend/.envs/.production/.litestream
DB_SETUP=litestream
LITESTREAM_ACCESS_KEY_ID="" # TODO : Generate random password
LITESTREAM_SECRET_ACCESS_KEY="" # TODO : Generate random password
S3_BUCKET_PATH="" # TODO : Create s3 bucket
EOF

mkdir -p provisionEB/.env
mkdir -p provisionEB/.ebextensions
cp backend/.envs/.production/.django provisionEB/.env/.django
cp backend/.envs/.production/.litestream provisionEB/.env/.litestream
# cp backend/.ebextensions/* provisionEB/.ebextensions/ # TODO : Add ebextensions

0 comments on commit 50570e2

Please sign in to comment.