2
0
mirror of https://github.com/offen/website.git synced 2024-12-22 21:10:23 +01:00

introduce staging environment

This commit is contained in:
Frederik Ring 2019-09-14 14:30:00 +02:00
parent b641784980
commit e0c6433e5f
3 changed files with 60 additions and 9 deletions

View File

@ -9,14 +9,18 @@ build_preconditions: &build_preconditions
- packages
filters:
branches:
only: /^master$/
only:
- master
- development
deploy_preconditions: &deploy_preconditions
requires:
- build
filters:
branches:
only: /^master$/
only:
- master
- development
jobs:
server:
@ -152,13 +156,20 @@ jobs:
build:
docker:
- image: docker:18-git
environment:
SITEURL: https://www.offen.dev
DOCKER_IMAGE_TAG: stable
working_directory: ~/offen
steps:
- checkout
- setup_remote_docker
- run:
name: Define target environment
command: |
if [ "${CIRCLE_BRANCH}" == "master" ]; then
echo 'export SITEURL="https://www.offen.dev"' >> $BASH_ENV
echo 'export DOCKER_IMAGE_TAG="stable"' >> $BASH_ENV
else
echo 'export SITEURL="https://staging.offen.dev"' >> $BASH_ENV
echo 'export DOCKER_IMAGE_TAG="latest"' >> $BASH_ENV
fi
- restore_cache:
keys:
- v1-{{ .Branch }}
@ -200,6 +211,14 @@ jobs:
- image: circleci/golang:1.12
steps:
- checkout
- run:
name: Define target environment
command: |
if [ "${CIRCLE_BRANCH}" == "master" ]; then
echo 'export TARGET_ENVIRONMENT="production"' >> $BASH_ENV
else
echo 'export TARGET_ENVIRONMENT="staging"' >> $BASH_ENV
fi
- run:
name: Install deployment dependencies
command: |
@ -211,11 +230,11 @@ jobs:
name: Run database migrations
working_directory: ~/offen/server
command: |
go run cmd/offen/main.go migrate -conn $(aws secretsmanager get-secret-value --secret-id production/postgresConnectionString | jq -r '.SecretString')
go run cmd/offen/main.go migrate -conn $(aws secretsmanager get-secret-value --secret-id $TARGET_ENVIRONMENT/postgresConnectionString | jq -r '.SecretString')
- run:
name: Deploy
command: |
cp Dockerrun.aws.json.production Dockerrun.aws.json
cp Dockerrun.aws.json.$TARGET_ENVIRONMENT Dockerrun.aws.json
eb deploy
workflows:

View File

@ -1,9 +1,10 @@
branch-defaults:
local-proxy:
environment: production
master:
environment: production
group_suffix: null
development:
environment: staging
group_suffix: null
global:
application_name: offen
branch: null

View 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": 256
}
]
}