diff --git a/.circleci/config.yml b/.circleci/config.yml index 107b0a0..909bc37 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,16 +1,6 @@ version: 2 -production_env: &production_env - environment: - - SERVER_HOST=https://server-alpha.offen.dev - - SCRIPT_HOST=https://script-alpha.offen.dev - - AUDITORIUM_HOST=https://auditorium-alpha.offen.dev - - VAULT_HOST=https://vault-alpha.offen.dev - - HOMEPAGE_HOST=https://www.offen.dev - - NODE_ENV=production - - SECRET_ID_SERVER_CONNECTION_STRING=alpha/server/postgresConnectionString - -deploy_preconditions: &deploy_preconditions +build_preconditions: &build_preconditions requires: - server - vault @@ -21,10 +11,12 @@ deploy_preconditions: &deploy_preconditions branches: only: /^master$/ -build_preconditions: &build_preconditions +deploy_preconditions: &deploy_preconditions + requires: + - build filters: branches: - ignore: gh-pages + only: /^master$/ jobs: server: @@ -156,74 +148,70 @@ jobs: name: Run tests command: npm test - deploy_homepage: + build: docker: - - image: circleci/python:3.6-node - working_directory: ~/offen/homepage - environment: - - SOURCE_BRANCH: master - - TARGET_BRANCH: gh-pages + - image: docker:18-git + working_directory: ~/offen steps: - - checkout: - path: ~/offen + - checkout + - setup_remote_docker - restore_cache: - key: offen-homepage-{{ checksum "requirements.txt" }} - - run: - name: Install dependencies - command: | - python -m venv venv - source venv/bin/activate - pip install -r requirements.txt - - save_cache: + keys: + - v1-{{ .Branch }} paths: - - ~/offen/homepage/venv - key: offen-homepage-{{ checksum "requirements.txt" }} + - /caches/proxy.tar + - /caches/server.tar - run: - name: Install image optimization deps + name: Load Docker image layer cache command: | - sudo npm install svgo -g - sudo apt-get install libjpeg-progs optipng + set +o pipefail + docker load -i /caches/app.tar | true - run: - name: Deploy + name: Build application Docker image command: | - source venv/bin/activate + docker build --cache-from=offen/proxy -t offen/proxy:latest -f build/proxy/Dockerfile . + docker build --cache-from=offen/server -t offen/server:latest -f build/server/Dockerfile . + - run: + name: Save Docker image layer cache + command: | + mkdir -p /caches + docker save -o /caches/proxy.tar offen/proxy + docker save -o /caches/server.tar offen/server + - save_cache: + key: v1-{{ .Branch }}-{{ epoch }} + paths: + - /caches/app.tar + - deploy: + name: Push application Docker image + command: | + echo "$DOCKER_PASS" | docker login --username $DOCKER_USER --password-stdin + docker push offen/server:latest + docker push offen/proxy:latest - git config --global user.email $GH_EMAIL - git config --global user.name $GH_NAME - - git clone $CIRCLE_REPOSITORY_URL out - - cd out - git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH - git rm -rf . - cd .. - - make publish - - cp -a output/. out/. - - mkdir -p out/.circleci && cp -a ./../.circleci/. out/.circleci/. - cp CNAME out/CNAME - cd out - - git add -A - git commit -m "Automated deployment to GitHub Pages: ${CIRCLE_SHA1}" --allow-empty - - git push origin $TARGET_BRANCH + deploy: + working_directory: ~/offen + docker: + - image: circleci/python:3.6 + steps: + - checkout + - run: + name: Installing deployment dependencies + command: | + sudo pip install awsebcli --upgrade + - run: + name: Deploying + command: eb deploy staging workflows: version: 2 test_build_deploy: jobs: - - server: + - server + - vault + - script + - auditorium + - packages + - build: <<: *build_preconditions - - vault: - <<: *build_preconditions - - script: - <<: *build_preconditions - - auditorium: - <<: *build_preconditions - - packages: - <<: *build_preconditions - - deploy_homepage: + - deploy: <<: *deploy_preconditions diff --git a/.ebignore b/.ebignore new file mode 100644 index 0000000..5712733 --- /dev/null +++ b/.ebignore @@ -0,0 +1,2 @@ +*.* +!Dockerrun.aws.json diff --git a/.elasticbeanstalk/config.yml b/.elasticbeanstalk/config.yml new file mode 100644 index 0000000..d90868c --- /dev/null +++ b/.elasticbeanstalk/config.yml @@ -0,0 +1,17 @@ +branch-defaults: + default: + environment: staging + group_suffix: null +global: + application_name: offen + branch: null + default_ec2_keyname: aws-eb + default_platform: Multi-container Docker 18.06.1-ce (Generic) + default_region: eu-central-1 + include_git_submodules: true + instance_profile: null + platform_name: null + platform_version: null + repository: null + sc: null + workspace_type: Application diff --git a/Dockerrun.aws.json b/Dockerrun.aws.json new file mode 100644 index 0000000..fce0391 --- /dev/null +++ b/Dockerrun.aws.json @@ -0,0 +1,31 @@ +{ + "AWSEBDockerrunVersion": 2, + "volumes": [], + "containerDefinitions": [ + { + "name": "proxy", + "image": "offen/proxy:latest", + "essential": true, + "memory": 128, + "portMappings": [ + { + "hostPort": 80, + "containerPort": 80 + } + ], + "dependsOn": [ + { + "containerName": "server", + "condition": "START" + } + ], + "links": ["server"] + }, + { + "name": "server", + "image": "offen/server:latest", + "essential": true, + "memory": 128 + } + ] +} diff --git a/Makefile b/Makefile index a25adf7..2ae75e7 100644 --- a/Makefile +++ b/Makefile @@ -23,8 +23,8 @@ bootstrap: @docker-compose run server make bootstrap build: - @docker build -t offen-server:latest -f build/server/Dockerfile . - @docker build -t offen-proxy:latest -f build/proxy/Dockerfile . + @docker build -t offen/server:latest -f build/server/Dockerfile . + @docker build -t offen/proxy:latest -f build/proxy/Dockerfile . secret: @docker-compose run server make secret diff --git a/build/docker-compose.yml b/build/docker-compose.yml deleted file mode 100644 index 0eef43d..0000000 --- a/build/docker-compose.yml +++ /dev/null @@ -1,24 +0,0 @@ -version: '3' - -services: - proxy: - image: offen-proxy:latest - ports: - - 3000:80 - depends_on: - - server - - server: - image: offen-server:latest - environment: - POSTGRES_CONNECTION_STRING: postgres://postgres:develop@server_database:5432/postgres?sslmode=disable - COOKIE_EXCHANGE_SECRET: Wsttdo4Z3mXV5sTc - EVENT_RETENTION_PERIOD: 4464h - ACCOUNT_USER_EMAIL_SALT: UwBkP24HCUYqy0Eq - depends_on: - - server_database - - server_database: - image: postgres:11.2 - environment: - POSTGRES_PASSWORD: develop diff --git a/homepage/theme/templates/base.html b/homepage/theme/templates/base.html index 160e6bd..4c29415 100644 --- a/homepage/theme/templates/base.html +++ b/homepage/theme/templates/base.html @@ -23,7 +23,7 @@ {% endassets %} {% if OFFEN_ACCOUNT_ID %} - + {% endif %}