mirror of
https://github.com/offen/website.git
synced 2024-11-22 09:00:28 +01:00
build docker images in ci
This commit is contained in:
parent
7c4b39e6d6
commit
b4e6faff48
@ -1,16 +1,6 @@
|
|||||||
version: 2
|
version: 2
|
||||||
|
|
||||||
production_env: &production_env
|
build_preconditions: &build_preconditions
|
||||||
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
|
|
||||||
requires:
|
requires:
|
||||||
- server
|
- server
|
||||||
- vault
|
- vault
|
||||||
@ -21,10 +11,12 @@ deploy_preconditions: &deploy_preconditions
|
|||||||
branches:
|
branches:
|
||||||
only: /^master$/
|
only: /^master$/
|
||||||
|
|
||||||
build_preconditions: &build_preconditions
|
deploy_preconditions: &deploy_preconditions
|
||||||
|
requires:
|
||||||
|
- build
|
||||||
filters:
|
filters:
|
||||||
branches:
|
branches:
|
||||||
ignore: gh-pages
|
only: /^master$/
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
server:
|
server:
|
||||||
@ -156,74 +148,70 @@ jobs:
|
|||||||
name: Run tests
|
name: Run tests
|
||||||
command: npm test
|
command: npm test
|
||||||
|
|
||||||
deploy_homepage:
|
build:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/python:3.6-node
|
- image: docker:18-git
|
||||||
working_directory: ~/offen/homepage
|
working_directory: ~/offen
|
||||||
environment:
|
|
||||||
- SOURCE_BRANCH: master
|
|
||||||
- TARGET_BRANCH: gh-pages
|
|
||||||
steps:
|
steps:
|
||||||
- checkout:
|
- checkout
|
||||||
path: ~/offen
|
- setup_remote_docker
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
key: offen-homepage-{{ checksum "requirements.txt" }}
|
keys:
|
||||||
- run:
|
- v1-{{ .Branch }}
|
||||||
name: Install dependencies
|
|
||||||
command: |
|
|
||||||
python -m venv venv
|
|
||||||
source venv/bin/activate
|
|
||||||
pip install -r requirements.txt
|
|
||||||
- save_cache:
|
|
||||||
paths:
|
paths:
|
||||||
- ~/offen/homepage/venv
|
- /caches/proxy.tar
|
||||||
key: offen-homepage-{{ checksum "requirements.txt" }}
|
- /caches/server.tar
|
||||||
- run:
|
- run:
|
||||||
name: Install image optimization deps
|
name: Load Docker image layer cache
|
||||||
command: |
|
command: |
|
||||||
sudo npm install svgo -g
|
set +o pipefail
|
||||||
sudo apt-get install libjpeg-progs optipng
|
docker load -i /caches/app.tar | true
|
||||||
- run:
|
- run:
|
||||||
name: Deploy
|
name: Build application Docker image
|
||||||
command: |
|
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
|
deploy:
|
||||||
git config --global user.name $GH_NAME
|
working_directory: ~/offen
|
||||||
|
docker:
|
||||||
git clone $CIRCLE_REPOSITORY_URL out
|
- image: circleci/python:3.6
|
||||||
|
steps:
|
||||||
cd out
|
- checkout
|
||||||
git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH
|
- run:
|
||||||
git rm -rf .
|
name: Installing deployment dependencies
|
||||||
cd ..
|
command: |
|
||||||
|
sudo pip install awsebcli --upgrade
|
||||||
make publish
|
- run:
|
||||||
|
name: Deploying
|
||||||
cp -a output/. out/.
|
command: eb deploy staging
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
workflows:
|
workflows:
|
||||||
version: 2
|
version: 2
|
||||||
test_build_deploy:
|
test_build_deploy:
|
||||||
jobs:
|
jobs:
|
||||||
- server:
|
- server
|
||||||
|
- vault
|
||||||
|
- script
|
||||||
|
- auditorium
|
||||||
|
- packages
|
||||||
|
- build:
|
||||||
<<: *build_preconditions
|
<<: *build_preconditions
|
||||||
- vault:
|
- deploy:
|
||||||
<<: *build_preconditions
|
|
||||||
- script:
|
|
||||||
<<: *build_preconditions
|
|
||||||
- auditorium:
|
|
||||||
<<: *build_preconditions
|
|
||||||
- packages:
|
|
||||||
<<: *build_preconditions
|
|
||||||
- deploy_homepage:
|
|
||||||
<<: *deploy_preconditions
|
<<: *deploy_preconditions
|
||||||
|
17
.elasticbeanstalk/config.yml
Normal file
17
.elasticbeanstalk/config.yml
Normal file
@ -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
|
31
Dockerrun.aws.json
Normal file
31
Dockerrun.aws.json
Normal file
@ -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
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
4
Makefile
4
Makefile
@ -23,8 +23,8 @@ bootstrap:
|
|||||||
@docker-compose run server make bootstrap
|
@docker-compose run server make bootstrap
|
||||||
|
|
||||||
build:
|
build:
|
||||||
@docker build -t offen-server:latest -f build/server/Dockerfile .
|
@docker build -t offen/server:latest -f build/server/Dockerfile .
|
||||||
@docker build -t offen-proxy:latest -f build/proxy/Dockerfile .
|
@docker build -t offen/proxy:latest -f build/proxy/Dockerfile .
|
||||||
|
|
||||||
secret:
|
secret:
|
||||||
@docker-compose run server make secret
|
@docker-compose run server make secret
|
||||||
|
@ -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
|
|
@ -23,7 +23,7 @@
|
|||||||
<link rel="stylesheet" href="/{{ ASSET_URL }}">
|
<link rel="stylesheet" href="/{{ ASSET_URL }}">
|
||||||
{% endassets %}
|
{% endassets %}
|
||||||
{% if OFFEN_ACCOUNT_ID %}
|
{% if OFFEN_ACCOUNT_ID %}
|
||||||
<script async src="https://script-alpha.offen.dev/script.js" data-account-id="{{ OFFEN_ACCOUNT_ID }}"></script>
|
<script async src="/script.js" data-account-id="{{ OFFEN_ACCOUNT_ID }}"></script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</head>
|
</head>
|
||||||
<body class="{{page.template}}">
|
<body class="{{page.template}}">
|
||||||
|
Loading…
Reference in New Issue
Block a user