mix release on prod env

This commit is contained in:
Jamil Bou Kheir
2020-11-13 13:52:30 -06:00
parent 974081e553
commit 7d50a38699
7 changed files with 83 additions and 26 deletions

View File

@@ -7,7 +7,7 @@ defaults:
jobs:
unit-integration-test:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
env:
MIX_ENV: test
POSTGRES_HOST: localhost
@@ -28,35 +28,41 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Install Runtimes
uses: actions/setup-elixir@v1
with:
elixir-version: "1.11.2"
otp-version: "23.1.2"
run: |
wget -O erlang.deb https://packages.erlang-solutions.com/erlang/debian/pool/esl-erlang_23.1-1~ubuntu~focal_amd64.deb
wget -O elixir.deb https://packages.erlang-solutions.com/erlang/debian/pool/elixir_1.11.2-1~ubuntu~focal_all.deb
sudo dpkg -i erlang.deb
sudo dpkg -i elixir.deb
- name: Install Dependencies
run: mix deps.get --only test
- name: Setup Database
run: |
mix ecto.create
mix ecto.migrate
- name: Run Tests and Upload Coverage Report
run: mix coveralls.github --umbrella
build:
needs: unit-integration-test
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Build packages
- name: Install runtimes
run: |
docker build -t fireguard:latest -f pkg/Dockerfile .
curl -sL https://deb.nodesource.com/setup_10.x | bash -
sudo apt install nodejs
wget -O erlang.deb https://packages.erlang-solutions.com/erlang/debian/pool/esl-erlang_23.1-1~ubuntu~focal_amd64.deb
wget -O elixir.deb https://packages.erlang-solutions.com/erlang/debian/pool/elixir_1.11.2-1~ubuntu~focal_all.deb
sudo dpkg -i erlang.deb
sudo dpkg -i elixir.deb
- name: Build release
run: |
scripts/build_prod_release.sh
scripts/build_fireguard_deb.sh
- name: Rename Built Artifacts
run: |
version="${{ steps.version.outputs.version }}"
cid=$(docker create fireguard:latest)
filename="fireguard_${{ github.sha }}-1_amd64.deb"
echo "Extracting built debian package from container ${cid} to filename ${filename}"
docker cp ${cid}:/build/pkg/debian.deb ./${filename}
cp fireguard_amd64.deb ./${filename}
- uses: actions/upload-artifact@v2
with:
name: fireguard-deb
@@ -108,7 +114,7 @@ jobs:
publish:
needs: build
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
steps:
- name: Create Release

3
.gitignore vendored
View File

@@ -46,3 +46,6 @@ npm-debug.log
# Development environment configuration
.env
# Built debian packages
*.deb

View File

@@ -15,10 +15,35 @@
- curl
- gnupg
- unzip
- dpkg-dev
- wireguard
- postgresql
- iptables
- net-tools
- automake
- autoconf
- libssl-dev
- libncurses5-dev
- zlib1g-dev
- locales
- build-essential
- ca-certificates
- name: setup nodejs repository
shell: curl -sL https://deb.nodesource.com/setup_10.x | bash -
- name: install nodejs
apt:
install_recommends: no
autoclean: yes
autoremove: yes
pkg:
- nodejs
- name: install erlang
apt:
deb: https://packages.erlang-solutions.com/erlang/debian/pool/esl-erlang_23.1-1~ubuntu~focal_amd64.deb
- name: install elixir
apt:
deb: https://packages.erlang-solutions.com/erlang/debian/pool/elixir_1.11.2-1~ubuntu~focal_all.deb
- name: Configure System
hosts: all
become: yes
@@ -33,11 +58,19 @@
line: 'net.ipv6.conf.all.forwarding = 1'
- name: apply sysctl
shell: sysctl -p
- name: Install FireGuard
- name: Build FireGuard
hosts: all
become: yes
tasks:
- name: Install FireGuard deb
- name: Compile Release
become: no
environment:
MIX_ENV: prod
shell: |
wget https://github.com/CloudFire-LLC/fireguard/releases/download/0.1.7/fireguard_amd64.deb
cd /vagrant
scripts/build_prod_release.sh
scripts/build_fireguard_deb.sh
- name: Install FireGuard deb
become: yes
shell: |
cd /vagrant
dpkg -i fireguard_amd64.deb

View File

@@ -1,4 +1,9 @@
# This Dockerfile builds release packages
# This Dockerfile builds release packages.
# **NOTE**: This is not recommended, as it's possible the deployment
# production environment will diff from the image environment here,
# even if the OS and kernel versions match.
# As such, this script has been deprecated in favor of building the release
# in the production environment.
FROM hexpm/elixir:1.11.2-erlang-23.1.2-ubuntu-focal-20201008 AS build
# Setup to run build script

View File

@@ -2,7 +2,7 @@ Package: fireguard
Version: 0.1.7-1
Architecture: amd64
Maintainer: CloudFire, LLC <dpkg@cloudfire.network>
Depends: net-tools (>= 1.60+git20180626.aebd88e-1ubuntu1), systemd (>= 245.4-4ubuntu3.2), openssl (>= 1.1.1f-1ubuntu2), wireguard (>= 1.0.20200319-1ubuntu1), postgresql (>= 12.4-0ubuntu0.20.04.1), iptables (>= 1.8.4-3ubuntu2)
Depends: net-tools (>= 1.60+git20180626.aebd88e-1ubuntu1), systemd (>= 245.4-4ubuntu3.2), openssl (>= 1.1.1f-1ubuntu2), wireguard (>= 1.0.20200319-1ubuntu1), postgresql (>= 12+214ubuntu0.1), iptables (>= 1.8.4-3ubuntu2)
Section: net
Priority: optional
Homepage: https://cloudfire.network

8
scripts/build_fireguard_deb.sh Executable file
View File

@@ -0,0 +1,8 @@
#!/usr/bin/env bash
od=$(pwd)
mkdir -p pkg/debian/opt
mv _build/prod/rel/fireguard pkg/debian/opt/fireguard
cd pkg
dpkg-deb --build debian
mv debian.deb fireguard_amd64.deb

View File

@@ -2,10 +2,12 @@
od=$(pwd)
export MIX_ENV=prod
cd apps/fg_http
npm run deploy --prefix assets
mix phx.digest
mix local.hex --force && mix local.rebar --force
mix do deps.get, deps.compile
cd apps/fg_http/assets && npm ci --progress=false --no-audit --loglevel=error
cd $od
mix release
npm run --prefix apps/fg_http/assets deploy
cd apps/fg_http
mix phx.digest
cd $od
mix release fireguard