-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Governance: Enhance CI/CD and preparation for hot reloads (#20)
* Refactor and introduce Code.status/0 * Require dialyxir in :prod env * Elixirize erlangish code * Use `npm ci` rather than `npm install` for release * Modify Dockerfile to create CI and release images * Add JobCache and JobConductor for heavy jobs * Add docker powered CICD * Modify ci job script * Import formatter configuration from distillery * Run mix format on rel/cofnig.ex * Include erts in dev release In order to generate hot upgrade erts must be included https://hexdocs.pm/distillery/guides/upgrades_and_downgrades.html * Randomize cookie for dev release * Cleanup release configuration overlays * Move calls to Application.app_dir/2 to runtime * Add CICD tests * Drop :src_branch configuration * Hook docker baked CICD to uniris app * Add CICD as a child to GovernanceSupervisor * Add moduledoc to Governance.Code.CICD * Configure git inside container
- Loading branch information
Showing
32 changed files
with
672 additions
and
513 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,70 @@ | ||
FROM bitwalker/alpine-elixir:latest | ||
|
||
# Install system requirements | ||
RUN apk add --no-cache --update | ||
openssl \ | ||
build-base \ | ||
gcc \ | ||
git \ | ||
npm \ | ||
python3 \ | ||
wget | ||
|
||
# Install Libsodium | ||
RUN wget https://download.libsodium.org/libsodium/releases/LATEST.tar.gz && \ | ||
mkdir /opt/libsodium && \ | ||
tar zxvf LATEST.tar.gz -C /opt/libsodium && \ | ||
cd /opt/libsodium/libsodium-stable && \ | ||
./configure && \ | ||
make && \ | ||
make install | ||
FROM elixir:alpine AS uniris-ci | ||
|
||
WORKDIR /opt/app | ||
# CI | ||
# - compile | ||
# - release | ||
# - gen PLT | ||
|
||
# running CI with proposal should generate release upgrade | ||
# - commit proposal | ||
# - compile | ||
# - run ci | ||
# - generate release upgrade | ||
|
||
######### TODO | ||
# TESTNET | ||
# - code | ||
# - release | ||
|
||
# running TESTNET with release upgrade should ??? | ||
|
||
ENV MIX_ENV prod | ||
RUN apk add --no-cache --update \ | ||
build-base bash gcc git npm python3 wget openssl libsodium-dev | ||
|
||
# Install hex and rebar | ||
RUN mix local.rebar --force \ | ||
&& mix local.hex --if-missing --force | ||
|
||
WORKDIR /opt/code | ||
|
||
COPY . . | ||
|
||
# Install dependencies | ||
# Cache Elixir deps | ||
RUN mix deps.get --only prod | ||
RUN mix deps.compile | ||
RUN git config user.name uniris \ | ||
&& git config user.email uniris@uniris.io \ | ||
&& git remote add origin https://github.com/UNIRIS/uniris-node | ||
|
||
WORKDIR /opt/app/assets | ||
# Compile | ||
RUN mix deps.get \ | ||
&& cd assets \ | ||
&& npm ci \ | ||
&& npm run deploy | ||
|
||
# Cache Node deps | ||
RUN npm install | ||
# Release | ||
RUN mix phx.digest \ | ||
&& mix distillery.release | ||
|
||
# Compile JavaScript | ||
RUN npm run deploy | ||
# gen PLT | ||
RUN mix git_hooks.run pre_push | ||
|
||
WORKDIR /opt/app | ||
# Install | ||
RUN mkdir /opt/app \ | ||
&& cd /opt/app \ | ||
&& tar zxf /opt/code/_build/dev/rel/uniris_node/releases/*/uniris_node.tar.gz | ||
CMD /opt/app/bin/uniris_node foreground | ||
|
||
# Prepare the image | ||
RUN mix compile | ||
RUN mix phx.digest | ||
################################################################################ | ||
|
||
FROM uniris-ci as build | ||
|
||
FROM alpine | ||
|
||
RUN apk add --no-cache --update bash git openssl libsodium | ||
|
||
COPY --from=build /opt/app /opt/app | ||
COPY --from=build /opt/code/.git /opt/code/.git | ||
|
||
WORKDIR /opt/code | ||
RUN git reset --hard | ||
|
||
WORKDIR /opt/app | ||
CMD /opt/app/bin/uniris_node foreground |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.