Skip to content

Commit

Permalink
Use 1P CLI for secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
dansahagian committed Aug 19, 2024
1 parent b23f28d commit 3cc30a9
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 36 deletions.
25 changes: 0 additions & 25 deletions .env.template

This file was deleted.

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ __pycache__
.idea/

.env
.env.prod

venv
.venv
Expand Down
6 changes: 4 additions & 2 deletions bin/deploy
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ rsync -a ./fbsurvivor dan@linode:/opt/fbsurvivor
rsync -a ./requirements dan@linode:/opt/fbsurvivor
rsync -a ./manage.py dan@linode:/opt/fbsurvivor
rsync -a ./bin dan@linode:/opt/fbsurvivor
rsync -a ./.env.prod dan@linode:/opt/fbsurvivor/.env
rsync -a ./prod.env dan@linode:/opt/fbsurvivor/prod.env

ssh linode "/opt/fbsurvivor/bin/deploy_on_server"
ssh linode /opt/fbsurvivor/bin/deploy_on_server $OP_SERVICE_ACCOUNT_TOKEN

sleep 2

curl -X GET -I https://fbsurvivor.com
13 changes: 6 additions & 7 deletions bin/deploy_on_server
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ cd /opt/fbsurvivor
echo "\nStopping services...\n"
sudo systemctl stop wsgi-server-fbsurvivor.service

.venv/bin/python manage.py migrate
.venv/bin/python manage.py collectstatic --no-input
.venv/bin/python manage.py check --deploy
export OP_SERVICE_ACCOUNT_TOKEN="$1"
export ENV=prod

op run --env-file="./prod.env" -- .venv/bin/python manage.py migrate
op run --env-file="./prod.env" -- .venv/bin/python manage.py collectstatic --no-input
op run --env-file="./prod.env" -- .venv/bin/python manage.py check --deploy

echo "\nStarting services...\n"
sudo systemctl start wsgi-server-fbsurvivor.service

sleep 2

rm .env
2 changes: 1 addition & 1 deletion fbsurvivor/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
SMTP_SENDER = config("SMTP_SENDER", "")
SMTP_USER = config("SMTP_USER", "")
SMTP_PASSWORD = config("SMTP_PASSWORD", "")
SMTP_PORT = config("SMTP_PORT", "")
SMTP_PORT = config("SMTP_PORT", 465)

if ENV == "dev":
DEBUG = True
Expand Down
17 changes: 17 additions & 0 deletions prod.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
DOMAIN="op://fbsurvivor/prod/domain"
SECRET_KEY="op://fbsurvivor/prod/secret_key"

CONTACT="op://fbsurvivor/prod/smtp_sender"
VENMO="op://fbsurvivor/prod/venmo"

PGHOST="op://fbsurvivor/prod/pghost"
PGDATABASE="op://fbsurvivor/prod/pgdatabase"
PGUSER="op://fbsurvivor/prod/pguser"
PGPASSWORD="op://fbsurvivor/prod/pgpassword"

SMTP_SERVER="op://fbsurvivor/prod/smtp_server"
SMTP_SENDER="op://fbsurvivor/prod/smtp_sender"
SMTP_USER="op://fbsurvivor/prod/smtp_user"
SMTP_PASSWORD="op://fbsurvivor/prod/smtp_password"

SENTRY_DSN="op://fbsurvivor/prod/sentry_dsn"

0 comments on commit 3cc30a9

Please sign in to comment.