Skip to content

Commit

Permalink
DSP-995 Building of Docker images on release (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
subotic authored Nov 5, 2020
1 parent b900931 commit c216051
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 5 deletions.
31 changes: 31 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# compiled output
/dist
/tmp

# dependencies
/node_modules
/bower_components

# IDEs and editors
/.idea
.project
.classpath
*.launch
.settings/

# misc
/.sass-cache
/connect.lock
/coverage/*
/libpeerconnection.log
npm-debug.log
testem.log
/typings

# e2e
/e2e/*.js
/e2e/*.map

#System Files
.DS_Store
Thumbs.db
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ root = true
[*]
charset = utf-8
indent_style = space
indent_size = 4
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: CI

on:
push:
release:
types: [published]

jobs:
test:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout Source
uses: actions/checkout@v1
with:
fetch-depth: 50
- name: Build Docker Image
run: make build-app-image
- name: Publish Docker Image (on release only)
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags')
run: |
echo ${{ secrets.DOCKER_HUB_TOKEN }} | docker login -u ${{ secrets.DOCKER_USER }} --password-stdin
make publish-app-image
38 changes: 38 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
### STAGE 1: Build ###

# We label our stage as 'builder'
FROM node:12-stretch as builder

# The qq is for silent output in the console
# You are welcome to modify this part as it
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev

# Sets the path where the app is going to be installed
ENV NODE_ROOT /usr/app/

# Creates the directory and all the parents (if they don’t exist)
RUN mkdir -p $NODE_ROOT

# Sets the /usr/app as the active directory
WORKDIR $NODE_ROOT

# Copies all the content
COPY . .

# Install all the packages
RUN npm install -g @angular/cli
RUN npm install

## Build the angular app in production mode and store the artifacts in dist folder
## should be: $(npm bin)/ng build --prod --env=prod --build-optimizer
RUN npm run build-prod

### STAGE 2: Setup ###

FROM dhlabbasel/nginx-server:v1.0.1

LABEL maintainer="400790+subotic@users.noreply.github.com"

RUN rm -rf /public/*

COPY --from=builder /usr/app/dist/limcweb /public
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Determine this makefile's path.
# Be sure to place this BEFORE `include` directives, if any.
# THIS_FILE := $(lastword $(MAKEFILE_LIST))
THIS_FILE := $(abspath $(lastword $(MAKEFILE_LIST)))
CURRENT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))

include vars.mk

.PHONY: build-app-image
build-app-image: ## build and publish APP image locally
docker build -t $(APP_IMAGE) .
docker tag $(APP_IMAGE) $(APP_REPO):latest

.PHONY: publish-app-image
publish-app-image: build-app-image ## publish APP Docker image to Docker-Hub
docker push $(APP_REPO)

.PHONY: help
help: ## this help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort

.DEFAULT_GOAL := help
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ You may find our live website at [weblimc.org](http://www.weblimc.org).
## Imprint

This web application has been developed from 2014 to 2019 by Andreas Aeschlimann, University of Basel.
It is maintained by Rita Gautschi, Data and Service Center for the Humanities, University of Basel.

Contact: a.aeschlimann@unibas.ch
Contact: rita.gautschi@dasch.swiss
4 changes: 2 additions & 2 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist",
"outputPath": "dist/limcweb",
"index": "src/index.html",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.json",
Expand Down Expand Up @@ -130,4 +130,4 @@
"prefix": "app"
}
}
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"start": "ng serve",
"test": "ng test",
"pree2e": "webdriver-manager update --standalone false --gecko false",
"e2e": "protractor"
"e2e": "protractor",
"build-prod": "ng build --prod --build-optimizer"
},
"private": true,
"dependencies": {
Expand Down
12 changes: 12 additions & 0 deletions vars.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
APP_REPO := daschswiss/080e-limc-app

ifeq ($(BUILD_TAG),)
BUILD_TAG := $(shell git describe --tag --dirty --abbrev=7)
endif
ifeq ($(BUILD_TAG),)
BUILD_TAG := $(shell git rev-parse --verify HEAD)
endif

ifeq ($(APP_IMAGE),)
APP_IMAGE := $(APP_REPO):$(BUILD_TAG)
endif

0 comments on commit c216051

Please sign in to comment.