-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from cmu-delphi/set-up-deployment
Prepares this application for deployment
- Loading branch information
Showing
8 changed files
with
160 additions
and
17 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# This file is used to allow CI to start the compose services. It will typcially | ||
# not need to be modified. | ||
|
||
MYSQL_DATABASE=mysql_database | ||
MYSQL_USER=mysql_user | ||
MYSQL_PASSWORD=mysql_password | ||
MYSQL_PORT=3306 | ||
MYSQL_ROOT_PASSWORD=test123! | ||
MYSQL_HOST=db | ||
|
||
ALLOWED_HOSTS='127.0.0.1,localhost' | ||
CORS_ORIGIN_WHITELIST='http://127.0.0.1:3000,http://localhost:3000' | ||
CSRF_TRUSTED_ORIGINS='http://127.0.0.1:8000,http://localhost:8000' | ||
|
||
SECRET_KEY='secret_key' | ||
DEBUG='True' | ||
|
||
# Add the following to your local .env file. They will be used in the CI process | ||
# and you can largely forget about them, but including them in your .env file | ||
# will act like a safe default and help suppress warnings. | ||
REGISTRY="" | ||
TAG="" |
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,57 @@ | ||
name: 'Build and deploy application containers' | ||
on: | ||
push: | ||
jobs: | ||
build-tag-push-deploy: | ||
runs-on: ubuntu-latest | ||
# CI/CD will run on these branches | ||
if: > | ||
github.ref == 'refs/heads/master' || | ||
github.ref == 'refs/heads/development' | ||
strategy: | ||
matrix: | ||
# Specify the docker-compose services to build images from | ||
service: [sdwebapp, sdnginx] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Login to GitHub container registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: cmu-delphi-deploy-machine | ||
password: ${{ secrets.CMU_DELPHI_DEPLOY_MACHINE_PAT }} | ||
- name: Create container image tags | ||
id: image-tag | ||
run: | | ||
baseRef="${GITHUB_REF#*/}" | ||
baseRef="${baseRef#*/}" | ||
case "${baseRef}" in | ||
master) | ||
image_tag="latest" | ||
;; | ||
*) | ||
image_tag="${baseRef//\//_}" # replace `/` with `_` in branch name | ||
;; | ||
esac | ||
echo "IMAGE_TAG=${image_tag}" >> $GITHUB_OUTPUT | ||
- name: Copy env file | ||
run: | | ||
cp ./.ci.env ./.env | ||
- name: Set up docker-compose | ||
uses: ndeloof/[email protected] | ||
- name: docker-compose build --push | ||
run: | | ||
docker-compose build --push ${{ matrix.service }} | ||
env: | ||
TAG: ":${{ steps.image-tag.outputs.IMAGE_TAG }}" | ||
REGISTRY: "ghcr.io/${{ github.repository_owner }}/" | ||
- name: docker-compose down | ||
run: | | ||
docker-compose down | ||
- name: Trigger smee.io webhook to pull new container images | ||
run: | | ||
curl -H "Authorization: Bearer ${{ secrets.DELPHI_DEPLOY_WEBHOOK_TOKEN }}" \ | ||
-X POST ${{ secrets.DELPHI_DEPLOY_WEBHOOK_URL }} \ | ||
-H "Content-Type: application/x-www-form-urlencoded" \ | ||
-d "repository=ghcr.io/${{ github.repository }}-${{ matrix.service }}&tag=${{ steps.image-tag.outputs.IMAGE_TAG }}" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
server { | ||
listen 80; | ||
server_name _; | ||
listen 80; | ||
server_name sdnginx; | ||
|
||
location / { | ||
proxy_set_header Host $http_host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
proxy_pass http://${APP_HOST}:8000; | ||
} | ||
location /static/ { | ||
autoindex on; | ||
alias /staticfiles/; | ||
} | ||
|
||
location /usr/src/signal_documentation { | ||
alias /static/; | ||
} | ||
location / { | ||
proxy_pass http://sdwebapp:8000/; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header Host $http_host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
} | ||
} |