mirror of
https://github.com/offen/website.git
synced 2024-11-21 16:50:27 +01:00
introduce staging environment
This commit is contained in:
parent
b641784980
commit
e0c6433e5f
@ -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:
|
||||
|
@ -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
|
||||
|
31
Dockerrun.aws.json.staging
Normal file
31
Dockerrun.aws.json.staging
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": 256
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user