Skip to content

Commit

Permalink
Docker Release (#34)
Browse files Browse the repository at this point in the history
* updated the project to use node 18LTS and npm as package manager;

* added DOckerfile and docker worklow to tagged releases

* added missing run instruction to npm in workflow file;
  • Loading branch information
hannesrichter authored Apr 2, 2023
1 parent c84dfae commit b8cf612
Show file tree
Hide file tree
Showing 40 changed files with 7,421 additions and 6,656 deletions.
19 changes: 13 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,16 @@ jobs:
name: Run Linter
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v2
- name: Install modules
run: yarn
- name: Run ESLint
run: npx eslint .
- name: Check out Git repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install modules
run: npm install

- name: Run ESLint
run: npm run lint
55 changes: 45 additions & 10 deletions .github/workflows/tagged-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ name: "tagged-release"
on:
push:
tags:
- "v*"
- "v*.*.*"

env:
IMAGE_NAME: "koi-pwa"

jobs:
tagged-release:
Expand All @@ -12,22 +15,54 @@ jobs:

steps:
- name: Check out Git repository
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18

- name: Install modules
run: yarn install --frozen-lockfile
run: npm install

- name: Lint
run: yarn lint
run: npm run lint

- name: Build
run: yarn build
- name: Package Release
run: npm run build

- name: Bundle Release
run: zip -r dist.zip dist
- uses: "marvinpinto/action-automatic-releases@latest"

- name: Build Dokcer Image
run: docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"

- name: publish the package as Release v*.*.*
uses: softprops/action-gh-release@v1
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
name: "Release ${{ github.ref_name }}"
body_path: CHANGELOG.md
generate_release_notes: false
files: dist.zip

- name: Login to GHCR.io
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin

- name: Push Docker Image
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### 1.3.0
- upgraded the project to Node.js 18 LTS
- switched to npm package manager
- added Dockerfile and automatic build of docker image on tagged release
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM nginx:stable-alpine3.17

# copy the dist folder and unzip it
COPY dist.zip /dist.zip
RUN unzip -o -q dist.zip -d /
RUN cp -rf /dist/* /usr/share/nginx/html/

COPY nginx-template.conf /nginx-template.conf

ENV PORT 80
ENV DOLLAR $
ENV API_URL http://localhost:8080

EXPOSE 80

ENTRYPOINT ["/bin/sh", "-c", "envsubst < /nginx-template.conf > /etc/nginx/nginx.conf && nginx -g 'daemon off;'"]
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ As such it allows the user to create, train, and deploy ML-solutions.

# Debug requirements
To run the application in debug mode, you need to install the following tools:
- Install: [Node.js](https://nodejs.org/en/) (<= 16.19.0)
- Install: [Node.js](https://nodejs.org/en/) (18 LTS)

Then run
- npm install

In the koi-pwa directory, you can run:
- npm start
Expand Down
39 changes: 39 additions & 0 deletions nginx-template.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
worker_processes 1;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

keepalive_timeout 65;

gzip on;
gzip_min_length 10240;
gzip_proxied any;
gzip_types *;

server {
listen ${PORT};
server_name ${DOLLAR}hostname;

add_header Cache-Control no-cache;

location /api {
proxy_set_header Host ${DOLLAR}host;
proxy_set_header X-Real-IP ${DOLLAR}remote_addr;
client_max_body_size 500M;
proxy_pass ${API_URL};
}

location / {
root /usr/share/nginx/html;
index index.html;
try_files ${DOLLAR}uri /index.html =404;
}

}

}
Loading

0 comments on commit b8cf612

Please sign in to comment.