From 03fc3625693cbfdb45141002ff386586e6222ec7 Mon Sep 17 00:00:00 2001 From: Timur Vafin Date: Wed, 28 Aug 2019 14:24:59 +0300 Subject: [PATCH 01/21] Remove .ruby-version since version specified in the Docker env --- .ruby-version | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .ruby-version diff --git a/.ruby-version b/.ruby-version deleted file mode 100644 index 73462a5..0000000 --- a/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -2.5.1 From 3ffd909b2fd0fa3aee07aeff964728140e49e8fc Mon Sep 17 00:00:00 2001 From: Timur Vafin Date: Wed, 28 Aug 2019 14:37:02 +0300 Subject: [PATCH 02/21] Try semaphore 2 with Docker --- .semaphore/semaphore.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .semaphore/semaphore.yml diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml new file mode 100644 index 0000000..1cef1fc --- /dev/null +++ b/.semaphore/semaphore.yml @@ -0,0 +1,15 @@ +# Run CI/CD jobs in Docker images: +# https://docs.semaphoreci.com/article/127-custom-ci-cd-environment-with-docker +version: v1.0 +name: Rails Base API +agent: + machine: + type: e1-standard-2 +blocks: + - name: Build + task: + jobs: + - name: Docker build + commands: + - checkout + - docker-compose build From 42a6afb59f9e1ca2defd8782e33771f23a352a0f Mon Sep 17 00:00:00 2001 From: Timur Vafin Date: Wed, 28 Aug 2019 14:44:40 +0300 Subject: [PATCH 03/21] Try e1-standard-8 --- .semaphore/semaphore.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 1cef1fc..8e83109 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -4,7 +4,8 @@ version: v1.0 name: Rails Base API agent: machine: - type: e1-standard-2 + type: e1-standard-8 + os_image: ubuntu1804 blocks: - name: Build task: From 4aab6773ddab1fe6ff9559b59b0294ecd0b40954 Mon Sep 17 00:00:00 2001 From: Timur Vafin Date: Wed, 28 Aug 2019 15:02:33 +0300 Subject: [PATCH 04/21] Setup BUNDLE_WITHOUT env --- .semaphore/semaphore.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 8e83109..f6b4467 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -1,14 +1,17 @@ -# Run CI/CD jobs in Docker images: -# https://docs.semaphoreci.com/article/127-custom-ci-cd-environment-with-docker version: v1.0 name: Rails Base API + agent: machine: type: e1-standard-8 os_image: ubuntu1804 + blocks: - name: Build task: + env_vars: + - name: BUNDLE_WITHOUT + value: development staging production jobs: - name: Docker build commands: From d429e94cdbcb7a6feda7d8a2fa29fcc66905a95a Mon Sep 17 00:00:00 2001 From: Timur Vafin Date: Wed, 28 Aug 2019 15:47:58 +0300 Subject: [PATCH 05/21] Push image to Dockerhub --- .semaphore/semaphore.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index f6b4467..4a50cf9 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -12,8 +12,15 @@ blocks: env_vars: - name: BUNDLE_WITHOUT value: development staging production + secrets: + - name: docker-secrets + prologue: + commands: + - echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin jobs: - name: Docker build commands: - checkout - docker-compose build + - docker tag rails_base_api:latest "flatstack/rails_base_api:$SEMAPHORE_WORKFLOW_ID + - docker push "flatstack/rails_base_api:$SEMAPHORE_WORKFLOW_ID From 096c347326094dd86907a2701fc2cf09ba66f72c Mon Sep 17 00:00:00 2001 From: Timur Vafin Date: Wed, 28 Aug 2019 15:50:49 +0300 Subject: [PATCH 06/21] Fix quotes --- .semaphore/semaphore.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 4a50cf9..13779e7 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -22,5 +22,5 @@ blocks: commands: - checkout - docker-compose build - - docker tag rails_base_api:latest "flatstack/rails_base_api:$SEMAPHORE_WORKFLOW_ID - - docker push "flatstack/rails_base_api:$SEMAPHORE_WORKFLOW_ID + - docker tag rails_base_api:latest "flatstack/rails_base_api:${SEMAPHORE_WORKFLOW_ID}" + - docker push "flatstack/rails_base_api:${SEMAPHORE_WORKFLOW_ID}" From 7ec7d35bb46916451548e9b6a883255127c2827a Mon Sep 17 00:00:00 2001 From: Timur Vafin Date: Wed, 28 Aug 2019 16:04:52 +0300 Subject: [PATCH 07/21] Try rspec --- .semaphore/semaphore.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 13779e7..8c3fabd 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -24,3 +24,26 @@ blocks: - docker-compose build - docker tag rails_base_api:latest "flatstack/rails_base_api:${SEMAPHORE_WORKFLOW_ID}" - docker push "flatstack/rails_base_api:${SEMAPHORE_WORKFLOW_ID}" + + - name: Run & Test Docker image + task: + secrets: + - name: docker-secrets + prologue: + commands: + # Authenticate with Docker Hub + - echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin + - checkout + - docker pull "flatstack/rails_base_api:${SEMAPHORE_WORKFLOW_ID}" + - docker tag "flatstack/rails_base_api:${SEMAPHORE_WORKFLOW_ID}" rails_base_api:latest + - docker-compose up -d + jobs: + - name: Check Running Images + commands: + - docker ps + - name: Run RSpec + commands: + - docker-compose exec app bin/rspec spec + - name: Run Quality + commands: + - docker-compose exec app bin/quality From d536158b7dc4111a2560f4bc29719c8eb676b539 Mon Sep 17 00:00:00 2001 From: Timur Vafin Date: Wed, 28 Aug 2019 16:14:18 +0300 Subject: [PATCH 08/21] Setup dotenv and db --- .semaphore/semaphore.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 8c3fabd..54663b6 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -34,9 +34,13 @@ blocks: # Authenticate with Docker Hub - echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin - checkout + # Pull image build on previous task - docker pull "flatstack/rails_base_api:${SEMAPHORE_WORKFLOW_ID}" - docker tag "flatstack/rails_base_api:${SEMAPHORE_WORKFLOW_ID}" rails_base_api:latest - - docker-compose up -d + - docker-compose up --detach + # Setup dotenv and database + - cp .env.example .env + docker-compose exec app bin/rails db:create db:schema:load jobs: - name: Check Running Images commands: From 23524e5dddb943e9d378446b2a287aded7a070e8 Mon Sep 17 00:00:00 2001 From: Timur Vafin Date: Wed, 28 Aug 2019 16:19:25 +0300 Subject: [PATCH 09/21] Fix typo --- .semaphore/semaphore.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 54663b6..1e0c4f3 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -16,12 +16,15 @@ blocks: - name: docker-secrets prologue: commands: + # Authenticate with Docker Hub - echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin jobs: - name: Docker build commands: + # Build image - checkout - docker-compose build + # Push image to DokerHub - docker tag rails_base_api:latest "flatstack/rails_base_api:${SEMAPHORE_WORKFLOW_ID}" - docker push "flatstack/rails_base_api:${SEMAPHORE_WORKFLOW_ID}" @@ -37,10 +40,11 @@ blocks: # Pull image build on previous task - docker pull "flatstack/rails_base_api:${SEMAPHORE_WORKFLOW_ID}" - docker tag "flatstack/rails_base_api:${SEMAPHORE_WORKFLOW_ID}" rails_base_api:latest - - docker-compose up --detach - # Setup dotenv and database + # Run setup dotenv and run container - cp .env.example .env - docker-compose exec app bin/rails db:create db:schema:load + - docker-compose up --detach + # Setup database + - docker-compose exec app bin/rails db:create db:schema:load jobs: - name: Check Running Images commands: From fc0baaafc70b74f7f1478dc85669586e1fc5e1ce Mon Sep 17 00:00:00 2001 From: Timur Vafin Date: Wed, 28 Aug 2019 16:48:34 +0300 Subject: [PATCH 10/21] Create tmp and log folder --- .semaphore/semaphore.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 1e0c4f3..6c87001 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -6,6 +6,14 @@ agent: type: e1-standard-8 os_image: ubuntu1804 +auto_cancel: + queued: + when: "true" + +fail_fast: + stop: + when: "true" + blocks: - name: Build task: @@ -42,6 +50,8 @@ blocks: - docker tag "flatstack/rails_base_api:${SEMAPHORE_WORKFLOW_ID}" rails_base_api:latest # Run setup dotenv and run container - cp .env.example .env + - mkdir log tmp + - chmod 777 log tmp - docker-compose up --detach # Setup database - docker-compose exec app bin/rails db:create db:schema:load From e070aa614aae4fa18f13dbd78aed415dd626e15c Mon Sep 17 00:00:00 2001 From: Timur Vafin Date: Wed, 28 Aug 2019 16:56:16 +0300 Subject: [PATCH 11/21] Create log and tmp correctly --- .semaphore/semaphore.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 6c87001..21eba67 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -50,7 +50,7 @@ blocks: - docker tag "flatstack/rails_base_api:${SEMAPHORE_WORKFLOW_ID}" rails_base_api:latest # Run setup dotenv and run container - cp .env.example .env - - mkdir log tmp + - mkdir -p log tmp - chmod 777 log tmp - docker-compose up --detach # Setup database From 2a16de6ae21fe264e7a1793bbf1abae643be3ce5 Mon Sep 17 00:00:00 2001 From: Timur Vafin Date: Wed, 28 Aug 2019 17:04:38 +0300 Subject: [PATCH 12/21] Try e1-standard-4 --- .semaphore/semaphore.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 21eba67..e7dc1b9 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -3,7 +3,7 @@ name: Rails Base API agent: machine: - type: e1-standard-8 + type: e1-standard-4 os_image: ubuntu1804 auto_cancel: @@ -36,7 +36,7 @@ blocks: - docker tag rails_base_api:latest "flatstack/rails_base_api:${SEMAPHORE_WORKFLOW_ID}" - docker push "flatstack/rails_base_api:${SEMAPHORE_WORKFLOW_ID}" - - name: Run & Test Docker image + - name: Run task: secrets: - name: docker-secrets From b77948952c08dc15d921fbad706b2dbcb754feb6 Mon Sep 17 00:00:00 2001 From: Timur Vafin Date: Wed, 28 Aug 2019 17:07:49 +0300 Subject: [PATCH 13/21] Set execution_time_limit to 1 hour --- .semaphore/semaphore.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index e7dc1b9..57f37a2 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -6,6 +6,9 @@ agent: type: e1-standard-4 os_image: ubuntu1804 +execution_time_limit: + hours: 1 + auto_cancel: queued: when: "true" From 063b1adec363695db876b9f5761b01ec871e3e4c Mon Sep 17 00:00:00 2001 From: Timur Vafin Date: Wed, 28 Aug 2019 17:29:10 +0300 Subject: [PATCH 14/21] Try to cache --- .semaphore/semaphore.yml | 41 +++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 57f37a2..e80e165 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -27,44 +27,63 @@ blocks: - name: docker-secrets prologue: commands: - # Authenticate with Docker Hub + # Authenticate with DockerHub - echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin jobs: - name: Docker build commands: - # Build image - checkout + + # Try to pull build image for this branch + - docker pull "flatstack/rails_base_api:${SEMAPHORE_GIT_BRANCH}" || true + + # Build image - docker-compose build - # Push image to DokerHub - - docker tag rails_base_api:latest "flatstack/rails_base_api:${SEMAPHORE_WORKFLOW_ID}" - - docker push "flatstack/rails_base_api:${SEMAPHORE_WORKFLOW_ID}" + + # Push image to DockerHub for the next tasks + - docker tag rails_base_api:latest "flatstack/rails_base_api:${SEMAPHORE_GIT_BRANCH}-${SEMAPHORE_WORKFLOW_ID}" + - docker push "flatstack/rails_base_api:${SEMAPHORE_GIT_BRANCH}-${SEMAPHORE_WORKFLOW_ID}" + + # Push images for the next builds + - docker tag rails_base_api:latest "flatstack/rails_base_api:${SEMAPHORE_GIT_BRANCH}" + - docker push "flatstack/rails_base_api:${SEMAPHORE_GIT_BRANCH}" - name: Run task: secrets: - name: docker-secrets + prologue: commands: - # Authenticate with Docker Hub - - echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin - checkout + + # Authenticate with DockerHub + - echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin + # Pull image build on previous task - - docker pull "flatstack/rails_base_api:${SEMAPHORE_WORKFLOW_ID}" - - docker tag "flatstack/rails_base_api:${SEMAPHORE_WORKFLOW_ID}" rails_base_api:latest - # Run setup dotenv and run container - - cp .env.example .env + - docker pull "flatstack/rails_base_api:${SEMAPHORE_GIT_BRANCH}-${SEMAPHORE_WORKFLOW_ID}" + - docker tag "flatstack/rails_base_api:${SEMAPHORE_GIT_BRANCH}-${SEMAPHORE_WORKFLOW_ID}" rails_base_api:latest + + # Fix Semaphore permissions bug - mkdir -p log tmp - chmod 777 log tmp + + # Run setup dotenv and run container + - cp .env.example .env - docker-compose up --detach + # Setup database - docker-compose exec app bin/rails db:create db:schema:load + jobs: - name: Check Running Images commands: - docker ps + - name: Run RSpec commands: - docker-compose exec app bin/rspec spec + - name: Run Quality commands: - docker-compose exec app bin/quality From 2d5eb9e6cf01971cfa657672421f615442d2c7b2 Mon Sep 17 00:00:00 2001 From: Timur Vafin Date: Wed, 28 Aug 2019 17:47:32 +0300 Subject: [PATCH 15/21] Setup docker-compose to build from cache --- .semaphore/semaphore.yml | 22 ++++++++++++++-------- docker-compose.yml | 2 ++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index e80e165..693de10 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -23,6 +23,12 @@ blocks: env_vars: - name: BUNDLE_WITHOUT value: development staging production + - name: DOCKER_REPO + value: flatstack/rails_base_api + - name: CACHE_IMAGE + value: "${DOCKER_REPO}:${SEMAPHORE_GIT_BRANCH}" + - name: WORKFLOW_CACHE_IMAGE + value: "${CACHE_IMAGE}-${SEMAPHORE_WORKFLOW_ID}" secrets: - name: docker-secrets prologue: @@ -34,19 +40,19 @@ blocks: commands: - checkout - # Try to pull build image for this branch - - docker pull "flatstack/rails_base_api:${SEMAPHORE_GIT_BRANCH}" || true + # Try to pull image for this branch + - docker pull "${CACHE_IMAGE}" || true # Build image - docker-compose build # Push image to DockerHub for the next tasks - - docker tag rails_base_api:latest "flatstack/rails_base_api:${SEMAPHORE_GIT_BRANCH}-${SEMAPHORE_WORKFLOW_ID}" - - docker push "flatstack/rails_base_api:${SEMAPHORE_GIT_BRANCH}-${SEMAPHORE_WORKFLOW_ID}" + - docker tag rails_base_api:latest "${WORKFLOW_CACHE_IMAGE}" + - docker push "${WORKFLOW_CACHE_IMAGE}" # Push images for the next builds - - docker tag rails_base_api:latest "flatstack/rails_base_api:${SEMAPHORE_GIT_BRANCH}" - - docker push "flatstack/rails_base_api:${SEMAPHORE_GIT_BRANCH}" + - docker tag rails_base_api:latest "${CACHE_IMAGE}" + - docker push "${CACHE_IMAGE}" - name: Run task: @@ -61,8 +67,8 @@ blocks: - echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin # Pull image build on previous task - - docker pull "flatstack/rails_base_api:${SEMAPHORE_GIT_BRANCH}-${SEMAPHORE_WORKFLOW_ID}" - - docker tag "flatstack/rails_base_api:${SEMAPHORE_GIT_BRANCH}-${SEMAPHORE_WORKFLOW_ID}" rails_base_api:latest + - docker pull "${WORKFLOW_CACHE_IMAGE}" + - docker tag "${WORKFLOW_CACHE_IMAGE}" rails_base_api:latest # Fix Semaphore permissions bug - mkdir -p log tmp diff --git a/docker-compose.yml b/docker-compose.yml index 1522a31..0f0d993 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,6 +22,8 @@ services: - MAILER_SENDER_ADDRESS build: context: . + cache_from: + - ${CACHE_IMAGE} args: - ADDITIONAL_PACKAGES=build-base git - BUNDLE_WITHOUT="${BUNDLE_WITHOUT}" From 94601b4bd177d9dc03cf3d802fbb2570d28d6b10 Mon Sep 17 00:00:00 2001 From: Timur Vafin Date: Wed, 28 Aug 2019 18:03:32 +0300 Subject: [PATCH 16/21] Setup envs from commands instead of env_vars --- .semaphore/semaphore.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 693de10..015c601 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -25,14 +25,14 @@ blocks: value: development staging production - name: DOCKER_REPO value: flatstack/rails_base_api - - name: CACHE_IMAGE - value: "${DOCKER_REPO}:${SEMAPHORE_GIT_BRANCH}" - - name: WORKFLOW_CACHE_IMAGE - value: "${CACHE_IMAGE}-${SEMAPHORE_WORKFLOW_ID}" secrets: - name: docker-secrets prologue: commands: + # Setup dynamic environment variables b/c they do not support via env_vars yet + - export CACHE_IMAGE="${DOCKER_REPO}:${SEMAPHORE_GIT_BRANCH}" + - export WORKFLOW_CACHE_IMAGE="${CACHE_IMAGE}-${SEMAPHORE_WORKFLOW_ID}" + # Authenticate with DockerHub - echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin jobs: From 879eb2aab7cdbd3e2f06063115caa6357853ef0b Mon Sep 17 00:00:00 2001 From: Timur Vafin Date: Wed, 28 Aug 2019 18:08:31 +0300 Subject: [PATCH 17/21] Set cache variable for Run task as well --- .semaphore/semaphore.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 015c601..24e4cc7 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -61,6 +61,10 @@ blocks: prologue: commands: + # Setup dynamic environment variables b/c they do not support via env_vars yet + - export CACHE_IMAGE="${DOCKER_REPO}:${SEMAPHORE_GIT_BRANCH}" + - export WORKFLOW_CACHE_IMAGE="${CACHE_IMAGE}-${SEMAPHORE_WORKFLOW_ID}" + - checkout # Authenticate with DockerHub From 890735943e8551d5cae853beba52f733e294f06a Mon Sep 17 00:00:00 2001 From: Timur Vafin Date: Wed, 28 Aug 2019 18:16:23 +0300 Subject: [PATCH 18/21] Add missing env --- .semaphore/semaphore.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 24e4cc7..df9568b 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -20,21 +20,20 @@ fail_fast: blocks: - name: Build task: - env_vars: - - name: BUNDLE_WITHOUT - value: development staging production - - name: DOCKER_REPO - value: flatstack/rails_base_api secrets: - name: docker-secrets + prologue: commands: # Setup dynamic environment variables b/c they do not support via env_vars yet + - export BUNDLE_WITHOUT="development staging production" + - export DOCKER_REPO="flatstack/rails_base_api" - export CACHE_IMAGE="${DOCKER_REPO}:${SEMAPHORE_GIT_BRANCH}" - export WORKFLOW_CACHE_IMAGE="${CACHE_IMAGE}-${SEMAPHORE_WORKFLOW_ID}" # Authenticate with DockerHub - echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin + jobs: - name: Docker build commands: @@ -62,6 +61,8 @@ blocks: prologue: commands: # Setup dynamic environment variables b/c they do not support via env_vars yet + - export BUNDLE_WITHOUT="development staging production" + - export DOCKER_REPO="flatstack/rails_base_api" - export CACHE_IMAGE="${DOCKER_REPO}:${SEMAPHORE_GIT_BRANCH}" - export WORKFLOW_CACHE_IMAGE="${CACHE_IMAGE}-${SEMAPHORE_WORKFLOW_ID}" From b97df1160d209f6bc49c473381c651bdf9775541 Mon Sep 17 00:00:00 2001 From: Timur Vafin Date: Wed, 28 Aug 2019 21:11:24 +0300 Subject: [PATCH 19/21] Set same guid for files in shared volume --- .semaphore/semaphore.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index df9568b..e1f1168 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -76,8 +76,7 @@ blocks: - docker tag "${WORKFLOW_CACHE_IMAGE}" rails_base_api:latest # Fix Semaphore permissions bug - - mkdir -p log tmp - - chmod 777 log tmp + - sudo chown 1000:1000 -R ./ # Run setup dotenv and run container - cp .env.example .env From 6dda2e8571269d8a6c05b3b088ed3f803a75154e Mon Sep 17 00:00:00 2001 From: Timur Vafin Date: Wed, 28 Aug 2019 21:12:15 +0300 Subject: [PATCH 20/21] Fix typo --- .semaphore/semaphore.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index e1f1168..54c04e8 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -78,7 +78,7 @@ blocks: # Fix Semaphore permissions bug - sudo chown 1000:1000 -R ./ - # Run setup dotenv and run container + # Setup dotenv and run container - cp .env.example .env - docker-compose up --detach From 8c6e7cb0a322aa98109c4e89a75f61973be1ed7b Mon Sep 17 00:00:00 2001 From: Timur Vafin Date: Wed, 28 Aug 2019 21:15:11 +0300 Subject: [PATCH 21/21] Reorder commands --- .semaphore/semaphore.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 54c04e8..6e4a2be 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -75,11 +75,13 @@ blocks: - docker pull "${WORKFLOW_CACHE_IMAGE}" - docker tag "${WORKFLOW_CACHE_IMAGE}" rails_base_api:latest + # Setup dotenv + - cp .env.example .env + # Fix Semaphore permissions bug - sudo chown 1000:1000 -R ./ - # Setup dotenv and run container - - cp .env.example .env + # Run container - docker-compose up --detach # Setup database