Addapt docker file

This commit is contained in:
SebClem 2024-08-13 13:23:32 +02:00
parent 98e789199e
commit 42adb7b563
Signed by: sebclem
GPG Key ID: 5A4308F6A359EA50
6 changed files with 70 additions and 32 deletions

View File

@ -13,7 +13,7 @@ env:
IMAGE_SOURCE: https://github.com/Sebclem/hassio-nextcloud-backup
jobs:
build-font:
build-front:
name: Build Front
runs-on: ubuntu-latest
steps:
@ -44,6 +44,41 @@ jobs:
name: front_dist
path: nextcloud_backup/frontend/dist/
build-back:
name: Build Front
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Enable corepack
run: corepack enable
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"
cache-dependency-path: nextcloud_backup/backend/pnpm-lock.yaml
- name: Install dependencies
run: pnpm i
working-directory: nextcloud_backup/backend
- name: Lint
run: pnpm lint
working-directory: nextcloud_backup/backend
- name: Build
run: pnpm build
working-directory: nextcloud_backup/backend
- name: Upload production-ready build files
uses: actions/upload-artifact@v4
with:
name: front_dist
path: nextcloud_backup/backend/dist/
# build-dockers:
# runs-on: ubuntu-latest
# strategy:

5
deploy
View File

@ -1,5 +0,0 @@
#!/bin/bash
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes && \
docker run --rm --privileged -v ~/.docker:/root/.docker -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd)/nextcloud_backup:/data homeassistant/amd64-builder --all -t /data

View File

@ -1,5 +1,28 @@
ARG BUILD_FROM=ghcr.io/hassio-addons/base/amd64:12.2.2
FROM ${BUILD_FROM}
FROM node:20 AS frontend-builder
WORKDIR /app
COPY frontend/package.json frontend/pnpm-lock.yaml ./
RUN corepack enable
RUN pnpm install
COPY frontend/ .
RUN pnpm build
FROM node:20 AS backend-builder
WORKDIR /app
COPY backend/package.json backend/pnpm-lock.yaml ./
RUN corepack enable
RUN pnpm install
COPY backend/ .
RUN pnpm build
FROM ghcr.io/hassio-addons/base/amd64:16.2.1
# Copy root filesystem
COPY rootfs/etc /etc/
@ -12,21 +35,17 @@ RUN apk add --no-cache nodejs-current
RUN mkdir -p /usr/local/sbin/
RUN ln -s /usr/bin/node /usr/local/sbin/node
# Copy only package*.json
COPY rootfs/opt/nextcloud_backup/package*.json /opt/nextcloud_backup/
COPY rootfs/opt/nextcloud_backup/.yarnrc.yml /opt/nextcloud_backup/
COPY rootfs/opt/nextcloud_backup/.yarn/releases/* /opt/nextcloud_backup/.yarn/releases/
WORKDIR /opt/nextcloud_backup/
# Enable Yarn
COPY backend/package.json backend/pnpm-lock.yaml ./
RUN corepack enable
# Install packages
RUN yarn install
RUN pnpm install
# Copy all source code
COPY rootfs/opt/ /opt/
COPY --from=backend-builder /app/dist .
COPY --from=frontend-builder /app/dist ./public
# Build arguments
ARG BUILD_ARCH
@ -48,8 +67,8 @@ LABEL \
org.label-schema.name="Nextcloud Backup" \
org.label-schema.schema-version="1.0" \
org.label-schema.url="https://addons.community" \
org.label-schema.usage="https://github.com/hassio-addons/addon-example/tree/master/README.md" \
org.label-schema.usage="https://github.com/Sebclem/hassio-nextcloud-backup/tree/master/README.md" \
org.label-schema.vcs-ref=${BUILD_REF} \
org.label-schema.vcs-url="https://github.com/hassio-addons/addon-example" \
org.label-schema.vcs-url="https://github.com/Sebclem/hassio-nextcloud-backup" \
org.label-schema.vendor="Sebclem"\
org.opencontainers.image.source=${IMAGE_SOURCE}

View File

@ -1,11 +0,0 @@
{
"folders": [
{
"path": "backend"
},
{
"path": "frontend"
}
],
"settings": {}
}

View File

@ -77,7 +77,7 @@ function postInit() {
() => {
logger.info("Cron: " + kleur.green().bold("Go !"));
},
(reason) => {
() => {
logger.info("Cron: " + kleur.red().bold("FAIL !"));
}
);

View File

@ -21,4 +21,4 @@ else
CREATE_BACKUP_TIMEOUT='info'
fi
LOG_LEVEL=$LOG_LEVEL CREATE_BACKUP_TIMEOUT=$CREATE_BACKUP_TIMEOUT yarn start
LOG_LEVEL=$LOG_LEVEL CREATE_BACKUP_TIMEOUT=$CREATE_BACKUP_TIMEOUT node server.js