Merge pull request #4 from CloudFire-LLC/ci-pipeline-workflow

Ci pipeline workflow
This commit is contained in:
Jamil
2020-04-26 14:18:04 -07:00
committed by GitHub
9 changed files with 142 additions and 77 deletions

View File

@@ -1,19 +0,0 @@
name: Build
description: 'Build and push docker images.'
on:
push:
branches:
- master
jobs:
build-app-image:
runs-on: ubuntu:18.04
steps:
- uses: actions/checkout@v2
- name: Build Docker Image
run: |
docker build -t cloudfirellc/cloudfire:${GITHUB_SHA::8} .
- name: Push Docker Image
run: |
docker push cloudfirellc/cloudfire:latest

View File

@@ -1,8 +0,0 @@
name: Deploy
description: "Deploy images"
on:
release: created
jobs:

76
.github/workflows/main.yml vendored Normal file
View File

@@ -0,0 +1,76 @@
# Steps:
# 1. Unit/Integration Tests
# 2. Build and Push App Image
# 3. Functional Test
name: Test
on:
- push
jobs:
# 1. Unit/Integration Test
unit-integration-test:
runs-on: ubuntu-18.04
env:
MIX_ENV: test
POSTGRES_HOST: localhost
services:
postgres:
image: postgres:12
ports:
- 5432:5432
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2
- name: Run Static Tests
uses: actions/setup-elixir@v1
with:
elixir-version: 1.10.2
otp-version: 22.3.2
- name: Install Dependencies
run: mix deps.get --only test
- name: Setup Database
run: |
mix ecto.create
mix ecto.migrate
- name: Run Tests
run: mix test
# 2. Build and Push App Image
build-app-image:
needs: unit-integration-test
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: azure/docker-login@v1
with:
login-server: docker.pkg.github.com
username: $GITHUB_ACTOR
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
run: |
export IMAGE="docker.pkg.github.com/cloudfire-llc/cloudfire-ce/cloudfire:${GITHUB_SHA::8}"
docker build -t $IMAGE .
docker push $IMAGE
# 3. Functional Test
docker-compose-up:
needs: build-app-image
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: azure/docker-login@v1
with:
login-server: docker.pkg.github.com
username: $GITHUB_ACTOR
password: ${{ secrets.GITHUB_TOKEN }}
- name: Functional Test
run: |
echo "TEST_IMAGE=docker.pkg.github.com/cloudfire-llc/cloudfire-ce/cloudfire:${GITHUB_SHA::8}" > .env
docker-compose -f docker-compose.yml -f docker-compose.test.yml up -d
echo 'Tests completed!'

View File

@@ -1,41 +0,0 @@
# Unit test
name: CI
on:
- push
- pull_request
jobs:
unit-test:
runs-on: ubuntu-18.04
env:
MIX_ENV: test
POSTGRES_HOST: localhost
services:
postgres:
image: postgres:12
ports:
- 5432:5432
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2
- name: Run Static Tests
uses: actions/setup-elixir@v1
with:
elixir-version: 1.10.2
otp-version: 22.3.2
- name: Install Dependencies
run: mix deps.get --only test
- name: Setup Database
run: |
mix ecto.create
mix ecto.migrate
- name: Run Tests
run: mix test

View File

@@ -29,7 +29,6 @@ RUN mix deps.compile
# Build assets
COPY $PHOENIX_DIR/assets $PHOENIX_DIR/assets
COPY priv priv
COPY $PHOENIX_DIR/priv $PHOENIX_DIR/priv
RUN npm install --prefix $PHOENIX_DIR/assets
RUN npm run deploy --prefix $PHOENIX_DIR/assets
@@ -40,8 +39,9 @@ COPY $PHOENIX_DIR/lib $PHOENIX_DIR/lib
COPY apps/system_engine/lib ./apps/system_engine/
RUN mix compile
# Build release
RUN mix release bundled
# Build releases
RUN mix release cf_phx
RUN mix release system_engine
# The built application is now contained in _build/
@@ -58,7 +58,7 @@ ENV PORT=4000 \
RUN mkdir /app
WORKDIR /app
COPY --from=builder /app/_build/prod/rel/bundled .
COPY --from=builder /app/_build/prod/rel/cf_phx /app/_build/prod/rel/system_engine ./
RUN chown -R nobody: /app
USER nobody

7
docker-compose.dev.yml Normal file
View File

@@ -0,0 +1,7 @@
version: "3.3"
services:
cf-phx:
build: ./
system-engine:
build: ./

6
docker-compose.test.yml Normal file
View File

@@ -0,0 +1,6 @@
version: "3.3"
services:
cf-phx:
image: ${TEST_IMAGE}
system-engine:
image: ${TEST_IMAGE}

44
docker-compose.yml Normal file
View File

@@ -0,0 +1,44 @@
# The base docker-compose
version: "3.3"
services:
cf-phx:
command: /app/bin/cf_phx start
image: cloudfirellc/cloudfire:latest
environment:
DATABASE_URL: ecto://postgres:postgres@db/cloudfire
# !! WARNING !!
# Change this for production systems!
# !!!!!!!!!!!!!
SECRET_KEY_BASE: vw5YEoG6Pb7mCQEC41DjJXIB6v1/tOxO+3YLN+5k+PILkcFMN54g22KXZr6o65Bn
ports:
- 4000:4000
networks:
- cloudfire
system-engine:
command: /app/bin/system_engine start
image: cloudfirellc/cloudfire:latest
networks:
- cloudfire
db:
networks:
- cloudfire
image: postgres:12
volumes:
- pg-data:/var/lib/postgresql/data
environment:
# !! WARNING !!
# Change this for production systems!
# !!!!!!!!!!!!!
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
volumes:
pg-data:
networks:
cloudfire:

10
mix.exs
View File

@@ -8,11 +8,11 @@ defmodule CloudfireUmbrella.MixProject do
start_permanent: Mix.env() == :prod,
deps: deps(),
releases: [
bundled: [
applications: [
cf_phx: :permanent,
system_engine: :permanent
]
cf_phx: [
applications: [cf_phx: :permanent]
],
system_engine: [
applications: [system_engine: :permanent]
]
]
]