add docker release action

This commit is contained in:
Simon Smith 2022-07-22 16:21:29 +01:00
parent da4f192b7a
commit 456b876ff7
3 changed files with 49 additions and 13 deletions

39
.github/workflows/docker.yml vendored Normal file
View File

@ -0,0 +1,39 @@
name: Docker
on:
release:
types: [published]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.MY_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
file: docker/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

View File

@ -16,6 +16,8 @@ jobs:
- name: Release - name: Release
uses: justincy/github-action-npm-release@2.0.2 uses: justincy/github-action-npm-release@2.0.2
id: release id: release
with:
token: ${{ secrets.MY_TOKEN }}
- name: Print release output - name: Print release output
if: ${{ steps.release.outputs.released == 'true' }} if: ${{ steps.release.outputs.released == 'true' }}
run: echo Release ID ${{ steps.release.outputs.release_id }} run: echo Release ID ${{ steps.release.outputs.release_id }}

View File

@ -1,10 +1,10 @@
FROM node:current-alpine AS base FROM node:current-alpine AS base
#Add non-root user, add installation directories and assign proper permissions #Add non-root user, add installation directories and assign proper permissions
RUN mkdir -p /opt/meshcentral RUN mkdir -p /opt/meshcentral/meshcentral
# meshcentral installation # meshcentral installation
WORKDIR /opt/meshcentral WORKDIR /opt/meshcentral/meshcentral
RUN apk add --no-cache bash RUN apk add --no-cache bash
@ -14,7 +14,6 @@ FROM base AS builder
ARG DISABLE_MINIFY="" ARG DISABLE_MINIFY=""
ARG DISABLE_TRANSLATE="" ARG DISABLE_TRANSLATE=""
RUN mkdir /opt/meshcentral/meshcentral
COPY ./ /opt/meshcentral/meshcentral/ COPY ./ /opt/meshcentral/meshcentral/
RUN if ! [ -z "$DISABLE_MINIFY" ] && [ "$DISABLE_MINIFY" != "yes" ] && [ "$DISABLE_MINIFY" != "YES" ] \ RUN if ! [ -z "$DISABLE_MINIFY" ] && [ "$DISABLE_MINIFY" != "yes" ] && [ "$DISABLE_MINIFY" != "YES" ] \
@ -26,15 +25,14 @@ RUN if ! [ -z "$DISABLE_TRANSLATE" ] && [ "$DISABLE_TRANSLATE" != "yes" ] && [ "
echo -e "\e[0;31;49mInvalid value for build argument DISABLE_TRANSLATE, possible values: yes/true\e[;0m"; exit 1; \ echo -e "\e[0;31;49mInvalid value for build argument DISABLE_TRANSLATE, possible values: yes/true\e[;0m"; exit 1; \
fi fi
# first try throws Error: Cannot find module 'jsdom' # first extractall if need too
RUN if [ -z "$DISABLE_MINIFY" ] || [ -z "$DISABLE_TRANSLATE" ]; then cd meshcentral/translate && node translate.js extractall; exit 0; fi RUN if [ -z "$DISABLE_MINIFY" ] || [ -z "$DISABLE_TRANSLATE" ]; then npm install html-minifier jsdom minify-js && cd translate && node translate.js extractall; fi
# minify files # minify files
RUN if [ -z "$DISABLE_MINIFY" ]; then cd meshcentral/translate && node translate.js minifyall; fi RUN if [ -z "$DISABLE_MINIFY" ]; then cd translate && node translate.js minifyall; fi
# translate # translate
RUN if [ -z "$DISABLE_TRANSLATE" ]; then cd meshcentral/translate && node translate.js extractall; fi RUN if [ -z "$DISABLE_TRANSLATE" ]; then cd translate && node translate.js translateall; fi
RUN if [ -z "$DISABLE_TRANSLATE" ]; then cd meshcentral/translate && node translate.js translateall; fi
FROM base FROM base
@ -56,11 +54,8 @@ COPY --from=builder /opt/meshcentral/meshcentral/docker/config.json.template /op
RUN rm -rf /opt/meshcentral/meshcentral/docker RUN rm -rf /opt/meshcentral/meshcentral/docker
RUN rm -rf /opt/meshcentral/meshcentral/node_modules RUN rm -rf /opt/meshcentral/meshcentral/node_modules
# install dependencies from package.json # install dependencies from package.json and nedb
RUN cd meshcentral && npm install RUN cd meshcentral && npm install && npm install nedb
# install dependencies for plugins
RUN cd meshcentral && npm install nedb
EXPOSE 80 443 4433 EXPOSE 80 443 4433