add docker release action

Simon Smith committed Jul 22, 2022 at 16:21 UTC 456b876ff7b07e41086ae501a0cfbcd756f4549f
3 files changed +49 -13
.github/workflows/docker.yml new
+39
@@ -0,0 +1,39 @@
1 +name: Docker
2 +on:
3 + release:
4 + types: [published]
5 +env:
6 + REGISTRY: ghcr.io
7 + IMAGE_NAME: ${{ github.repository }}
8 +jobs:
9 + build:
10 + name: Release
11 + runs-on: ubuntu-latest
12 + steps:
13 + - name: Checkout
14 + uses: actions/checkout@v3
15 + with:
16 + fetch-depth: 0
17 + - name: Set up QEMU
18 + uses: docker/setup-qemu-action@v2
19 + - name: Set up Docker Buildx
20 + uses: docker/setup-buildx-action@v2
21 + - name: Log in to the Container registry
22 + uses: docker/login-action@v2
23 + with:
24 + registry: ${{ env.REGISTRY }}
25 + username: ${{ github.actor }}
26 + password: ${{ secrets.MY_TOKEN }}
27 + - name: Extract metadata (tags, labels) for Docker
28 + id: meta
29 + uses: docker/metadata-action@v4
30 + with:
31 + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
32 + - name: Build and push Docker image
33 + uses: docker/build-push-action@v2
34 + with:
35 + context: .
36 + file: docker/Dockerfile
37 + push: true
38 + tags: ${{ steps.meta.outputs.tags }}
39 + labels: ${{ steps.meta.outputs.labels }}
.github/workflows/release.yml
+2
@@ -16,6 +16,8 @@ jobs:
16 - name: Release
17 uses: justincy/github-action-npm-release@2.0.2
18 id: release
19 + with:
20 + token: ${{ secrets.MY_TOKEN }}
21 - name: Print release output
22 if: ${{ steps.release.outputs.released == 'true' }}
23 run: echo Release ID ${{ steps.release.outputs.release_id }}
docker/Dockerfile
+8 -13
@@ -1,10 +1,10 @@
1 FROM node:current-alpine AS base
2
3 #Add non-root user, add installation directories and assign proper permissions
4 -RUN mkdir -p /opt/meshcentral
4 +RUN mkdir -p /opt/meshcentral/meshcentral
5
6 # meshcentral installation
7 -WORKDIR /opt/meshcentral
7 +WORKDIR /opt/meshcentral/meshcentral
8
9 RUN apk add --no-cache bash
10
@@ -14,7 +14,6 @@ FROM base AS builder
14 ARG DISABLE_MINIFY=""
15 ARG DISABLE_TRANSLATE=""
16
17 -RUN mkdir /opt/meshcentral/meshcentral
17 COPY ./ /opt/meshcentral/meshcentral/
18
19 RUN if ! [ -z "$DISABLE_MINIFY" ] && [ "$DISABLE_MINIFY" != "yes" ] && [ "$DISABLE_MINIFY" != "YES" ] \
@@ -26,15 +25,14 @@ RUN if ! [ -z "$DISABLE_TRANSLATE" ] && [ "$DISABLE_TRANSLATE" != "yes" ] && [ "
25 echo -e "\e[0;31;49mInvalid value for build argument DISABLE_TRANSLATE, possible values: yes/true\e[;0m"; exit 1; \
26 fi
27
29 -# first try throws Error: Cannot find module 'jsdom'
30 -RUN if [ -z "$DISABLE_MINIFY" ] || [ -z "$DISABLE_TRANSLATE" ]; then cd meshcentral/translate && node translate.js extractall; exit 0; fi
28 +# first extractall if need too
29 +RUN if [ -z "$DISABLE_MINIFY" ] || [ -z "$DISABLE_TRANSLATE" ]; then npm install html-minifier jsdom minify-js && cd translate && node translate.js extractall; fi
30
31 # minify files
33 -RUN if [ -z "$DISABLE_MINIFY" ]; then cd meshcentral/translate && node translate.js minifyall; fi
32 +RUN if [ -z "$DISABLE_MINIFY" ]; then cd translate && node translate.js minifyall; fi
33
34 # translate
36 -RUN if [ -z "$DISABLE_TRANSLATE" ]; then cd meshcentral/translate && node translate.js extractall; fi
37 -RUN if [ -z "$DISABLE_TRANSLATE" ]; then cd meshcentral/translate && node translate.js translateall; fi
35 +RUN if [ -z "$DISABLE_TRANSLATE" ]; then cd translate && node translate.js translateall; fi
36
37
38 FROM base
@@ -56,11 +54,8 @@ COPY --from=builder /opt/meshcentral/meshcentral/docker/config.json.template /op
54 RUN rm -rf /opt/meshcentral/meshcentral/docker
55 RUN rm -rf /opt/meshcentral/meshcentral/node_modules
56
59 -# install dependencies from package.json
60 -RUN cd meshcentral && npm install
61 -
62 -# install dependencies for plugins
63 -RUN cd meshcentral && npm install nedb
57 +# install dependencies from package.json and nedb
58 +RUN cd meshcentral && npm install && npm install nedb
59
60 EXPOSE 80 443 4433
61