Skip to content

Commit 5313f0c

Browse files
committed
shio: Add build files
1 parent 1748c6f commit 5313f0c

5 files changed

Lines changed: 91 additions & 70 deletions

File tree

.github/workflows/main.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: main
2+
3+
on:
4+
push:
5+
branches:
6+
- shio/*
7+
tags:
8+
- '*_shio.*'
9+
pull_request:
10+
branches:
11+
- shio/*
12+
13+
env:
14+
DOCKER_BUILDKIT: 1
15+
OCI_REGISTRY: rg.nl-ams.scw.cloud/shio-solutions
16+
OCI_REPO: tales-media/fork/opencast-editor
17+
18+
jobs:
19+
build-and-push:
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- uses: docker/login-action@v3
26+
if: ${{ github.event_name == 'push' }}
27+
with:
28+
registry: ${{ env.OCI_REGISTRY }}
29+
username: nologin
30+
password: ${{ secrets.SCW_SECRET_KEY }}
31+
32+
- name: info
33+
run: |
34+
docker version
35+
docker info
36+
37+
- name: set tag version
38+
if: ${{ github.ref_type == 'tag' }}
39+
run: |
40+
echo "${{ github.ref_name }}" > VERSION
41+
42+
- name: build
43+
run: |
44+
docker build --pull --no-cache \
45+
--build-arg VERSION="$(cat VERSION)" \
46+
--build-arg BUILD_DATE="$(date -u -Iseconds)" \
47+
--build-arg GIT_COMMIT="${{ github.sha }}" \
48+
-t "${OCI_REGISTRY}/${OCI_REPO}:latest" \
49+
-t "${OCI_REGISTRY}/${OCI_REPO}:${{ github.sha }}" \
50+
-t "${OCI_REGISTRY}/${OCI_REPO}:$(cat VERSION)" \
51+
.
52+
53+
- name: push
54+
if: ${{ github.event_name == 'push' }}
55+
run: |
56+
docker push "${OCI_REGISTRY}/${OCI_REPO}:$(cat VERSION)"
57+
58+
- name: push latest
59+
if: ${{ github.event_name == 'push' && github.ref_type == 'branch' }}
60+
run: |
61+
docker push "${OCI_REGISTRY}/${OCI_REPO}:latest"

Dockerfile

Lines changed: 26 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,38 @@
1-
# syntax=docker/dockerfile:1.4
1+
ARG NODE_VERSION=20
2+
FROM docker.io/library/node:${NODE_VERSION}-alpine AS build
23

3-
ARG NODE_VERSION=16
4-
FROM node:${NODE_VERSION}-alpine as build
5-
6-
RUN apk add --no-cache git
74
WORKDIR /src
85
COPY package.json .
96
COPY package-lock.json .
10-
RUN npm i
7+
RUN npm ci
118
COPY / .
129

13-
ARG PUBLIC_URL=/
14-
ARG REACT_APP_SETTINGS_PATH=/editor-settings.toml
10+
ARG PUBLIC_URL=/editor-ui
11+
ARG VITE_APP_SETTINGS_PATH=/ui/config/editor/editor-settings.toml
12+
ARG VERSION=unknown
13+
ARG BUILD_DATE=unknown
14+
ARG GIT_COMMIT=unknown
1515
RUN npm run build
1616

1717

18-
ARG NODE_VERSION=16
19-
FROM node:${NODE_VERSION}-alpine as caddy
20-
21-
RUN apk add --no-cache curl
22-
23-
ARG CADDY_VERSION=2.5.1
24-
25-
RUN curl -sSL "https://github.com/caddyserver/caddy/releases/download/v${CADDY_VERSION}/caddy_${CADDY_VERSION}_linux_amd64.tar.gz" | tar xzf - caddy \
26-
&& chown 0:0 caddy \
27-
&& chmod +x caddy
28-
RUN mkdir -p /rootfs/config /rootfs/data \
29-
&& chown 1000:1000 /rootfs/config /rootfs/data
30-
31-
32-
FROM scratch
33-
34-
ENV XDG_CONFIG_HOME /config
35-
ENV XDG_DATA_HOME /data
36-
37-
COPY <<EOF /Caddyfile
38-
{
39-
admin off
40-
}
41-
42-
:80 {
43-
root * /www
44-
file_server
45-
}
46-
47-
:2019 {
48-
metrics /metrics
49-
respond /healthz 200
50-
}
51-
EOF
52-
53-
COPY <<EOF /etc/nsswitch.conf
54-
hosts: files dns
55-
EOF
56-
57-
COPY --from=caddy /rootfs /
58-
COPY --from=caddy /caddy /
59-
COPY --from=build /src/build /www
60-
61-
USER 1000:1000
18+
FROM rg.nl-ams.scw.cloud/shio-solutions/infra/static-site:1
6219

63-
EXPOSE 80
64-
EXPOSE 443
65-
EXPOSE 2019
20+
ARG PUBLIC_URL=/editor-ui
21+
ARG VERSION=unknown
22+
ARG BUILD_DATE=unknown
23+
ARG GIT_COMMIT=unknown
6624

67-
LABEL org.opencontainers.image.title "Opencast Video Editor"
68-
LABEL org.opencontainers.image.description "Web-based video editor for Opencast"
69-
LABEL org.opencontainers.image.vendor "Opencast"
70-
LABEL org.opencontainers.image.licenses "Apache-2.0"
71-
LABEL org.opencontainers.image.url "https://github.com/opencast/opencast-editor"
72-
LABEL org.opencontainers.image.documentation "https://github.com/opencast/opencast-editor"
73-
LABEL org.opencontainers.image.source "https://github.com/opencast/opencast-editor"
25+
COPY --from=build /src/build "/www/${PUBLIC_URL}"
7426

75-
ENTRYPOINT [ "/caddy" ]
76-
CMD ["run", "--config", "/Caddyfile", "--adapter", "caddyfile"]
27+
LABEL maintainer="shio solutions GmbH <dev@shio.solutions>" \
28+
org.opencontainers.image.title="Opencast Video Editor" \
29+
org.opencontainers.image.description="Web-based video editor for Opencast" \
30+
org.opencontainers.image.version="${VERSION}" \
31+
org.opencontainers.image.vendor="shio solutions GmbH" \
32+
org.opencontainers.image.authors="shio solutions GmbH <dev@shio.solutions>" \
33+
org.opencontainers.image.licenses="Apache-2.0" \
34+
org.opencontainers.image.url="https://github.com/tales-media/fork-opencast-opencast-editor" \
35+
org.opencontainers.image.documentation="https://github.com/tales-media/fork-opencast-opencast-editor" \
36+
org.opencontainers.image.source="https://github.com/tales-media/fork-opencast-opencast-editor" \
37+
org.opencontainers.image.created="${BUILD_DATE}" \
38+
org.opencontainers.image.revision="${GIT_COMMIT}"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ To build a container image, run:
4242
--build-arg NODE_VERSION=16 \
4343
--build-arg CADDY_VERSION=2.5.1 \
4444
--build-arg PUBLIC_URL=/ \
45-
--build-arg REACT_APP_SETTINGS_PATH=/editor-settings.toml \
45+
--build-arg VITE_APP_SETTINGS_PATH=/editor-settings.toml \
4646
-t quay.io/opencast/editor .
4747

4848
Configuration

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
19_shio

vite.config.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import { defineConfig } from "vite";
22
import react from "@vitejs/plugin-react";
33
import svgr from "vite-plugin-svgr";
4-
import child from "child_process";
54
import { configDefaults } from 'vitest/config'
65

7-
const commitHash = child.execSync("git rev-parse HEAD").toString().trim();
8-
96
// https://vitejs.dev/config/
107
export default defineConfig(() => {
118
return {
@@ -29,8 +26,8 @@ export default defineConfig(() => {
2926
// Workaround, see https://github.com/vitejs/vite/discussions/5912#discussioncomment-6115736
3027
define: {
3128
global: "globalThis",
32-
'import.meta.env.VITE_GIT_COMMIT_HASH': JSON.stringify(commitHash),
33-
'import.meta.env.VITE_APP_BUILD_DATE': JSON.stringify(new Date().toISOString()),
29+
'import.meta.env.VITE_GIT_COMMIT_HASH': JSON.stringify(process.env.GIT_COMMIT || "unknown"),
30+
'import.meta.env.VITE_APP_BUILD_DATE': JSON.stringify(process.env.BUILD_DATE || "unknown"),
3431
},
3532
test: {
3633
globals: true,

0 commit comments

Comments
 (0)