diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..333da79b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +./node_modules +.git +.direnv +.envrc \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..afb1c337 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,19 @@ +name: build + +on: [workflow_dispatch] + +jobs: + everything: + runs-on: ubuntu-latest + steps: + - name: Get Repo + uses: actions/checkout@v2 + - name: Run script + shell: bash + run: | + chmod +x ./build-scripts/ci-build.sh + ./build-scripts/ci-build.sh + - uses: actions/upload-artifact@v3 + with: + name: lamassu-server.tar.gz + path: ./lamassu-server.tar.gz diff --git a/build/Dockerfile.ci b/build/Dockerfile.ci new file mode 100644 index 00000000..22f731ac --- /dev/null +++ b/build/Dockerfile.ci @@ -0,0 +1,39 @@ +FROM ubuntu:20.04 as base + +ARG VERSION +ARG DEBIAN_FRONTEND=noninteractive +ENV TZ=Europe/Lisbon + +RUN apt-get update + +RUN apt-get install -y -q curl \ + sudo \ + git \ + python2-minimal \ + build-essential \ + libpq-dev \ + net-tools \ + tar + +RUN curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - +RUN apt-get install nodejs -y -q + +FROM base as l-s-build + +WORKDIR lamassu-server + +# # Prevent cache invalidation when we only change version numbers +COPY ["package.json", "package-lock.json", "./"] +RUN npm version --allow-same-version --git-tag-version false --commit-hooks false 1.0.0 +RUN npm install --production + +COPY . ./ +RUN rm -rf public/* + +RUN cd new-lamassu-admin && npm install && npm run build +RUN cp -r new-lamassu-admin/build/* public +RUN rm -rf new-lamassu-admin/node_modules + +RUN cd .. && tar -zcvf lamassu-server.tar.gz ./lamassu-server + +ENTRYPOINT [ "/bin/bash" ] \ No newline at end of file diff --git a/build/ci-build.sh b/build/ci-build.sh new file mode 100644 index 00000000..ac212ce1 --- /dev/null +++ b/build/ci-build.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -e + +docker build -t build:latest -f build-scripts/Dockerfile.ci build-scripts/Dockerfile.ci . + +id=$(docker create build) +docker cp $id:/lamassu-server.tar.gz ./lamassu-server.tar.gz +docker rm -v $id