Skip to content

Commit

Permalink
Merge pull request #21 from airgap-it/feat/beacon-v2
Browse files Browse the repository at this point in the history
Feat/beacon v2
  • Loading branch information
AndreasGassmann authored Dec 9, 2020
2 parents 98c2cb4 + 156993a commit fdbcf57
Show file tree
Hide file tree
Showing 61 changed files with 9,592 additions and 7,071 deletions.
54 changes: 32 additions & 22 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,43 @@
#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------

FROM node:12
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.148.1/containers/typescript-node/.devcontainer/base.Dockerfile

# Avoid warnings by switching to noninteractive
ENV DEBIAN_FRONTEND=noninteractive
# [Choice] Node.js version: 14, 12, 10
ARG VARIANT="14-buster"
FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:0-${VARIANT}

# Configure apt and install packages
RUN apt-get update \
&& apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
#
# Verify git and needed tools are installed
&& apt-get -y install git iproute2 procps \
#
# Install zsh
# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>

RUN apt-get update \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
&& apt-get install -y zsh \
&& wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh || true \
#
# Install ionic
&& npm install -g ionic \
# install libraries
&& apt-get install -yyq libappindicator1 libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 \
# tools
&& apt-get install -yyq gconf-service lsb-release wget xdg-utils \
# and fonts
&& apt-get install -yyq fonts-liberation \
# We install Chrome to get all the OS level dependencies, but Chrome itself
# is not actually used as it's packaged in the node puppeteer library.
# Alternatively, we could could include the entire dep list ourselves
# (https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md#chrome-headless-doesnt-launch-on-unix)
# but that seems too easy to get out of date.
&& apt-get install -y google-chrome-stable \
&& rm -rf /var/lib/apt/lists/* \
&& wget --quiet https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh -O /usr/sbin/wait-for-it.sh \
&& chmod +x /usr/sbin/wait-for-it.sh \
#
# Clean up
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

# [Optional] Uncomment if you want to install an additional version of node using nvm
# ARG EXTRA_NODE_VERSION=10
# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"

# Switch back to dialog for any ad-hoc use of apt-get
ENV DEBIAN_FRONTEND=dialog
# [Optional] Uncomment if you want to install more global node packages
# RUN sudo -u node npm install -g <your-package-list -here>
RUN sudo -u node npm install -g @ionic/cli
48 changes: 23 additions & 25 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or the definition README at
// https://github.com/microsoft/vscode-dev-containers/tree/master/containers/javascript-node-12
{
"name": "Node.js 12 - Ionic",
"dockerFile": "Dockerfile",
//
// Use 'settings' to set *default* container specific settings.json values on container create.
// You can edit these settings after create using File > Preferences > Settings > Remote.
"name": "Node.js & TypeScript",
"build": {
"dockerfile": "Dockerfile",
// Update 'VARIANT' to pick a Node version: 10, 12, 14
"args": { "VARIANT": "14" }
},

// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/zsh"
},
//
// Use 'appPort' to create a container with published ports. If the port isn't working, be sure
// your server accepts connections from all interfaces (0.0.0.0 or '*'), not just localhost.
"appPort": ["8103:8100"],
//
// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": "yarn install",
//
// Uncomment the next line to have VS Code connect as an existing non-root user in the container.
// On Linux, by default, the container user's UID/GID will be updated to match your local user. See
// https://aka.ms/vscode-remote/containers/non-root for details on adding a non-root user if none exist.
// "remoteUser": "node",
//
// Add the IDs of extensions you want installed when the container is created in the array below.

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"dbaeumer.vscode-eslint",
// TSLint is included for backwards compatibility, but is deprecated.
// See https://github.com/palantir/tslint/issues/4534
"ms-vscode.vscode-typescript-tslint-plugin",
"esbenp.prettier-vscode"
]
"angular.ng-template",
"esbenp.prettier-vscode",
"eamodio.gitlens"
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "yarn install",

// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "node"
}
43 changes: 43 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build

on: push

jobs:
build_angular:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Cache node modules
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Node 14
uses: actions/setup-node@v1
with:
node-version: 14.x

- name: Prepare
run: npm ci

# - name: Prettier
# run: npm run actions:prettier

- name: Build
run: npm run build:prod

# - name: Unit Tests
# run: npm test -- --configuration=ci

# - name: E2E Tests
# run: npm run e2e -- --configuration=ci

- name: Upload
uses: actions/upload-artifact@v1
with:
name: beacon-extension
path: www
30 changes: 8 additions & 22 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
image: docker:latest

variables:
IMAGE_TAG: $CI_REGISTRY_IMAGE
IMAGE_TAG_CURRENT: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
IMAGE_TAG_LATEST: $CI_REGISTRY_IMAGE:latest
IMAGE_TAG_ANDROID_CURRENT: $CI_REGISTRY_IMAGE:android-$CI_COMMIT_SHA
IMAGE_TAG_ANDROID_LATEST: $CI_REGISTRY_IMAGE:android-latest
GOOGLE_TAG: eu.gcr.io/papers-kubernetes/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:$CI_COMMIT_SHA
GOOGLE_TAG_EXTENSION_CURRENT: eu.gcr.io/papers-kubernetes/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:extension-$CI_COMMIT_SHA

stages:
- build
Expand All @@ -15,14 +12,8 @@ stages:

build_ionic:
stage: build
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
script:
- docker build --cache-from $IMAGE_TAG_LATEST -t $IMAGE_TAG .
- docker tag $IMAGE_TAG $IMAGE_TAG_CURRENT
- docker tag $IMAGE_TAG $IMAGE_TAG_LATEST
- docker push $IMAGE_TAG_CURRENT
- docker push $IMAGE_TAG_LATEST
- docker build -t $GOOGLE_TAG .
tags:
- docker

Expand All @@ -46,25 +37,20 @@ build_ionic:
# - lintReport.json

build_extension:
image: $IMAGE_TAG_CURRENT
stage: native_build
when: manual
script:
- sed -i -e "s/VERSION_NUMBER/$VERSION/g" src/app/services/app-info/app-info.service.ts
- sed -i -e "s/VERSION_CODE/$CI_PIPELINE_ID/g" src/app/services/app-info/app-info.service.ts
# - sed -i -e "/\"version\"/c\ \"version\" :\"$VERSION\"," src/manifest.json
- npm install
- npm install ionic
- npm run postinstall
- npm run build:prod
- mv www beacon-extension
- docker build -f build/extension/Dockerfile -t $GOOGLE_TAG_EXTENSION_CURRENT --build-arg VERSION="$VERSION" --build-arg CI_PIPELINE_ID="$CI_PIPELINE_ID" .
- docker run --name extension-$CI_PIPELINE_ID $GOOGLE_TAG_EXTENSION_CURRENT echo "container ran."
- docker cp extension-$CI_PIPELINE_ID:/app/www beacon-extension
after_script:
- docker rm -f extension-$CI_PIPELINE_ID || true
artifacts:
name: 'beacon-extension'
paths:
- beacon-extension/
tags:
- docker

# qa:
# stage: qa
# before_script:
Expand Down
2 changes: 1 addition & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "12mb"
"maximumError": "18mb"
}
]
},
Expand Down
47 changes: 47 additions & 0 deletions build/extension/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
FROM beevelop/ionic:v5.2.3

RUN apt-get update -y && apt-get install -y \
bzip2 \
build-essential \
pkg-config \
libjpeg-dev \
libcairo2-dev

# create app directory
RUN mkdir /app
WORKDIR /app

# using npm 6.5.0 to fix installing certain cordova/ionic plugins
RUN npm install -g [email protected] @ionic/cli
RUN npm cache clean -f
RUN npm install -g n
RUN n 10.14.1

# Install app dependencies, using wildcard if package-lock exists
COPY package.json /app/package.json
COPY package-lock.json /app/package-lock.json

# install dependencies
RUN npm ci

RUN mkdir www

# Bundle app source
COPY . /app

# post-install hook, to be safe if it got cached
RUN node scripts/patch-crypto.js
RUN ls

# set version code
ARG VERSION
ARG CI_PIPELINE_ID
RUN sed -i -e "s/VERSION_NUMBER/$VERSION/g" src/app/services/app-info/app-info.service.ts
RUN sed -i -e "s/VERSION_CODE/$CI_PIPELINE_ID/g" src/app/services/app-info/app-info.service.ts
# RUN sed -i -e "/\"version\"/c\ \"version\" :\"$VERSION\"," src/manifest.json

# fix crypto libraries
RUN npm run postinstall

# build ionic
RUN npm run build:prod
Loading

0 comments on commit fdbcf57

Please sign in to comment.