Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerhub ci ecs #10

Open
wants to merge 7 commits into
base: dockerhub_ci
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 38 additions & 3 deletions .github/workflows/docker-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ on:
push:
branches:
- dev
- dockerhub_ci_ecs
pull_request:
branches:
- dev
Expand Down Expand Up @@ -48,19 +49,19 @@ jobs:
run: docker-compose -f docker/docker-compose.test.yml down

- name: Save physionet image
if: github.ref == 'refs/heads/dev' || github.event.inputs.publish_tag
if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/dockerhub_ci_ecs' || github.event.inputs.publish_tag
run: docker save physionet:latest | gzip > /tmp/physionet.tar.gz

- name: Upload physionet image
if: github.ref == 'refs/heads/dev' || github.event.inputs.publish_tag
if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/dockerhub_ci_ecs' || github.event.inputs.publish_tag
uses: actions/upload-artifact@v2
with:
name: physionet
path: /tmp/physionet.tar.gz

publish:
name: Publish to DockerHub
if: github.ref == 'refs/heads/dev' || github.event.inputs.publish_tag
if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/dockerhub_ci_ecs' || github.event.inputs.publish_tag
environment: dockerhub
runs-on: ubuntu-latest
needs: build
Expand All @@ -86,3 +87,37 @@ jobs:
docker tag physionet:latest physionet/physionet:${{ github.event.inputs.publish_tag || 'latest' }}
docker push physionet/physionet:${GITHUB_SHA}
docker push physionet/physionet:${{ github.event.inputs.publish_tag || 'latest' }}

deploy_ecs:
name: Deploy ECS
needs: publish
environment: dockerhub
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/dockerhub_ci_ecs'
steps:
- name: Configure aws credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2

- name: Update ECS
run: |
aws ecs describe-task-definition --task-definition physionet --query taskDefinition > task-definition.json

- name: Update ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: task-definition.json
container-name: physionet
image: physionet/physionet:${GITHUB_SHA}

- name: Deploy task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: task-definition.json
service: physionet-service
cluster: physionet-cluster
wait-for-service-stability: true
4 changes: 4 additions & 0 deletions physionet-django/physionet/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
# Application definition

INSTALLED_APPS = [
'whitenoise.runserver_nostatic',
'dal',
'dal_select2',
'django.contrib.admin',
Expand All @@ -58,6 +59,7 @@

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'physionet.middleware.maintenance.SystemMaintenanceMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
Expand All @@ -67,6 +69,8 @@
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

STATICFILES_STORAGE = 'whitenoise.storage.CompressedStaticFilesStorage'

CRON_CLASSES = [
"physionet.cron.RemoveUnverifiedEmails",
"physionet.cron.RemoveOutstandingInvites",
Expand Down
21 changes: 16 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ psycopg2 = "~2.8.6"
httplib2 = "^0.19.0"
oauthlib = "^3.1.0"
requests-oauthlib = "^1.3.0"
whitenoise = "^5.3.0"

[tool.poetry.dev-dependencies]
coverage = "^4.4.2"
Expand Down
4 changes: 4 additions & 0 deletions uwsgi.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[uwsgi]
http-socket = 0.0.0.0:8000
module = physionet.wsgi:application
chdir = physionet-django