Skip to content

Commit

Permalink
Build production image (#250)
Browse files Browse the repository at this point in the history
* Build production image

* seperate the tool script
  • Loading branch information
mark86092 authored Jul 31, 2017
1 parent 239c5be commit 621d35a
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 13 deletions.
38 changes: 25 additions & 13 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,8 @@ jobs:
steps:
- checkout
- run:
name: Install Docker client
command: |
set -x
VER="17.03.0-ce"
curl -L -o /tmp/docker-$VER.tgz https://get.docker.com/builds/Linux/x86_64/docker-$VER.tgz
tar -xz -C /tmp -f /tmp/docker-$VER.tgz
mv /tmp/docker/* /usr/bin
- run:
name: Install Docker Compose
command: |
set -x
curl -L https://github.com/docker/compose/releases/download/1.13.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
name: Install Docker client & Docker Compose
command: ./.circleci/prepare-docker-compose.sh
- setup_remote_docker
- run:
name: Build Docker Image
Expand All @@ -56,6 +45,25 @@ jobs:
curl --user ${CIRCLE_API_TOKEN_FOR_DEPLOY}: \
--data build_parameters[CIRCLE_JOB]=build \
https://circleci.com/api/v1.1/project/github/mark86092/goodjob-deploy-ci/tree/www-stage
build_production_docker:
working_directory: ~/app
docker:
- image: buildpack-deps
steps:
- checkout
- run:
name: Install Docker client & Docker Compose
command: ./.circleci/prepare-docker-compose.sh
- setup_remote_docker
- run:
name: Build Docker Image
command: docker-compose -f .circleci/docker-compose-production.yml build
- run:
name: Retag
command: docker tag 059402281999.dkr.ecr.ap-northeast-1.amazonaws.com/goodjob/goodjobshare:production 059402281999.dkr.ecr.ap-northeast-1.amazonaws.com/goodjob/goodjobshare:production-${CIRCLE_SHA1}
- run: docker login -u $AWS_DOCKER_USER -p $AWS_DOCKER_PASS https://059402281999.dkr.ecr.ap-northeast-1.amazonaws.com
- run: docker-compose -f .circleci/docker-compose-production.yml push
- run: docker push 059402281999.dkr.ecr.ap-northeast-1.amazonaws.com/goodjob/goodjobshare:production-${CIRCLE_SHA1}
workflows:
version: 2
build_and_test:
Expand All @@ -65,6 +73,10 @@ workflows:
filters:
branches:
only: master
- build_production_docker:
filters:
branches:
only: master
- deploy-stage:
requires:
- build
Expand Down
13 changes: 13 additions & 0 deletions .circleci/docker-compose-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: "2"
services:
node:
image: 059402281999.dkr.ecr.ap-northeast-1.amazonaws.com/goodjob/goodjobshare:production
build:
context: ..
dockerfile: docker/Dockerfile
args:
- API_HOST=https://tranquil-fortress-92731.herokuapp.com
- CONTENTFUL_API_HOST=https://content.goodjob.life
- FACEBOOK_APP_ID=1750216878594984
ports:
- 42000:3001
13 changes: 13 additions & 0 deletions .circleci/prepare-docker-compose.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -x

# install docker
VER="17.03.0-ce"
curl -L -o /tmp/docker-$VER.tgz https://get.docker.com/builds/Linux/x86_64/docker-$VER.tgz
tar -xz -C /tmp -f /tmp/docker-$VER.tgz
mv /tmp/docker/* /usr/bin

# prepare docker-compose
curl -L https://github.com/docker/compose/releases/download/1.13.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

0 comments on commit 621d35a

Please sign in to comment.