Skip to content
Snippets Groups Projects
Unverified Commit f127bcf4 authored by Ahmad Farhat's avatar Ahmad Farhat Committed by GitHub
Browse files

Added checks for db before starting (#4077)

parent 9cb90a61
No related branches found
No related tags found
No related merge requests found
env:
RUBY_VERSION: 3.1
name: CI Build Pre-Release
on:
release:
types: [prereleased]
jobs:
main:
name: Build Docker Image
env:
DOCKER_REPOSITORY: ${{ secrets.DOCKER_REPOSITORY }}
DOCKER_BUILD_ENABLED: ${{ secrets.DOCKER_BUILD_ENABLED }}
DOCKER_BUILD_ALTERNATE_ENABLED: ${{ secrets.DOCKER_BUILD_ALTERNATE_ENABLED }}
runs-on: ubuntu-20.04
steps:
- name: Checkout
if: contains(env.DOCKER_BUILD_ENABLED, 'true')
uses: actions/checkout@v2
- name: Set up Docker Buildx
if: contains(env.DOCKER_BUILD_ENABLED, 'true')
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
if: contains(env.DOCKER_BUILD_ENABLED, 'true')
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to DockerHub
if: contains(env.DOCKER_BUILD_ENABLED, 'true')
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract Docker Repository
id: ci_docker_repository
if: contains(env.DOCKER_BUILD_ENABLED, 'true')
shell: bash
run: echo "##[set-output name=repository;]$(echo ${DOCKER_REPOSITORY:-$GITHUB_REPOSITORY})"
- name: Extract Tag Release
id: ci_tag_release_version
if: contains(env.DOCKER_BUILD_ENABLED, 'true')
shell: bash
run: echo "##[set-output name=tag;]$(echo ${GITHUB_REF#refs/tags/} | cut -c 9-)"
- name: Build and Push
if: contains(env.DOCKER_BUILD_ENABLED, 'true')
uses: docker/build-push-action@v2
with:
push: true
tags: |
"${{ steps.ci_docker_repository.outputs.repository }}:v${{ steps.ci_tag_release_version.outputs.tag }}"
build-args: "VERSION_TAG=release-${{ steps.ci_tag_release_version.outputs.tag }}"
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
# Alternate Images with alpine
- name: Alternate Alpine Build and Push
if: contains(env.DOCKER_BUILD_ENABLED, 'true') && contains(env.DOCKER_BUILD_ALTERNATE_ENABLED, 'true')
uses: docker/build-push-action@v2
with:
file: dockerfiles/v2/alpine
push: true
tags: |
"${{ steps.ci_docker_repository.outputs.repository }}:v${{ steps.ci_tag_release_version.outputs.tag }}-alpine"
build-args: "VERSION_TAG=release-${{ steps.ci_tag_release_version.outputs.tag }}"
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
# Alternate Images with amazonlinux
- name: Alternate Amazon Linux Build and Push
if: contains(env.DOCKER_BUILD_ENABLED, 'true') && contains(env.DOCKER_BUILD_ALTERNATE_ENABLED, 'true')
uses: docker/build-push-action@v2
with:
file: dockerfiles/v2/amazonlinux
push: true
tags: |
"${{ steps.ci_docker_repository.outputs.repository }}:v${{ steps.ci_tag_release_version.outputs.tag }}-amazonlinux"
build-args: "VERSION_TAG=release-${{ steps.ci_tag_release_version.outputs.tag }}"
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
- name: Move cache
if: contains(env.DOCKER_BUILD_ENABLED, 'true')
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
\ No newline at end of file
...@@ -6,6 +6,17 @@ fi ...@@ -6,6 +6,17 @@ fi
export PORT="${PORT:=3000}" export PORT="${PORT:=3000}"
echo "Web app starting on port: $PORT" echo "Web app starting on port: $PORT"
if [ "$RAILS_ENV" = "production" ]; then
while ! rails db:version 2>/dev/null
do
echo "Waiting for postgres to start up ..."
sleep 1
done
fi
rails db:create
rails db:migrate:with_data
rails assets:precompile rails assets:precompile
rails s -b 0.0.0.0 -p $PORT rails s -b 0.0.0.0 -p $PORT
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment