mirror of
https://github.com/offen/website.git
synced 2024-11-22 01:00:26 +01:00
introduce staging environment
This commit is contained in:
parent
b641784980
commit
e0c6433e5f
@ -9,14 +9,18 @@ build_preconditions: &build_preconditions
|
|||||||
- packages
|
- packages
|
||||||
filters:
|
filters:
|
||||||
branches:
|
branches:
|
||||||
only: /^master$/
|
only:
|
||||||
|
- master
|
||||||
|
- development
|
||||||
|
|
||||||
deploy_preconditions: &deploy_preconditions
|
deploy_preconditions: &deploy_preconditions
|
||||||
requires:
|
requires:
|
||||||
- build
|
- build
|
||||||
filters:
|
filters:
|
||||||
branches:
|
branches:
|
||||||
only: /^master$/
|
only:
|
||||||
|
- master
|
||||||
|
- development
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
server:
|
server:
|
||||||
@ -152,13 +156,20 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
docker:
|
docker:
|
||||||
- image: docker:18-git
|
- image: docker:18-git
|
||||||
environment:
|
|
||||||
SITEURL: https://www.offen.dev
|
|
||||||
DOCKER_IMAGE_TAG: stable
|
|
||||||
working_directory: ~/offen
|
working_directory: ~/offen
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
- setup_remote_docker
|
- 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:
|
- restore_cache:
|
||||||
keys:
|
keys:
|
||||||
- v1-{{ .Branch }}
|
- v1-{{ .Branch }}
|
||||||
@ -200,6 +211,14 @@ jobs:
|
|||||||
- image: circleci/golang:1.12
|
- image: circleci/golang:1.12
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- 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:
|
- run:
|
||||||
name: Install deployment dependencies
|
name: Install deployment dependencies
|
||||||
command: |
|
command: |
|
||||||
@ -211,11 +230,11 @@ jobs:
|
|||||||
name: Run database migrations
|
name: Run database migrations
|
||||||
working_directory: ~/offen/server
|
working_directory: ~/offen/server
|
||||||
command: |
|
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:
|
- run:
|
||||||
name: Deploy
|
name: Deploy
|
||||||
command: |
|
command: |
|
||||||
cp Dockerrun.aws.json.production Dockerrun.aws.json
|
cp Dockerrun.aws.json.$TARGET_ENVIRONMENT Dockerrun.aws.json
|
||||||
eb deploy
|
eb deploy
|
||||||
|
|
||||||
workflows:
|
workflows:
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
branch-defaults:
|
branch-defaults:
|
||||||
local-proxy:
|
|
||||||
environment: production
|
|
||||||
master:
|
master:
|
||||||
environment: production
|
environment: production
|
||||||
group_suffix: null
|
group_suffix: null
|
||||||
|
development:
|
||||||
|
environment: staging
|
||||||
|
group_suffix: null
|
||||||
global:
|
global:
|
||||||
application_name: offen
|
application_name: offen
|
||||||
branch: null
|
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