Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker #146

Merged
merged 33 commits into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b4f71bb
docker: initial config
cpvalente May 24, 2022
8fa6bce
docker: add entrypoint for headless run
cpvalente May 24, 2022
251638b
docker: resolve path from env variable
cpvalente May 24, 2022
5eff38f
docker: initial config
cpvalente May 24, 2022
b9da74a
docker: rename preloaded data directories
cpvalente May 24, 2022
fd2f442
docker: update README
cpvalente May 24, 2022
ec1ffcc
docker: prevent issue with port mappings
cpvalente May 26, 2022
57160da
docker: prevent issue with port mappings
cpvalente May 26, 2022
1a0941f
docker: update README.md
cpvalente May 26, 2022
a335954
docker: update README.md
cpvalente May 26, 2022
cb03a5d
docker: add docker-compose
cpvalente May 26, 2022
7def13e
docker: cleanup logs
cpvalente May 27, 2022
4f05338
docker: add CI
cpvalente May 27, 2022
c92b71d
docker: cleanup unused
cpvalente May 27, 2022
4c207a2
docker: use static port in development
cpvalente May 27, 2022
fd694b8
refactor: isolate tasks
cpvalente May 27, 2022
5f02727
docker: add demo db
cpvalente May 27, 2022
a5d4192
fix: download db resolves according to OS
cpvalente May 27, 2022
18da548
fix: download db resolves according to OS
cpvalente May 27, 2022
02973d8
docker: config build
cpvalente May 28, 2022
a687acc
fix: ensure db path exists
cpvalente May 28, 2022
30147be
fix: add object type to block
cpvalente May 28, 2022
e1b8157
docker: config build
cpvalente May 29, 2022
ae66343
docker: config build
cpvalente May 29, 2022
21de1d0
docker: env is production
cpvalente May 29, 2022
72e07dd
docker: preload db
cpvalente May 29, 2022
21f4428
fix: remove test dir
cpvalente May 29, 2022
fab135e
docker: graceful shutdown node app
cpvalente May 29, 2022
77b8235
docker: env is production
cpvalente May 29, 2022
c12bca8
docker: add docker-compose
cpvalente May 31, 2022
1e7a013
docker: remove unused mappings
cpvalente Jun 8, 2022
47a0bb7
docker: version bump
cpvalente Jun 8, 2022
e8ddc32
docker: merge master
cpvalente Jun 8, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Ignore config files
.prettier*

# Ignore install stuff
**/yarn.lock
**/yarn-error.log

# Ignore test files
**/__tests__/**
**/**.test.js

# Ignore git and cache folders
.git
.cache
103 changes: 0 additions & 103 deletions .github/workflows/autobuild.yml

This file was deleted.

62 changes: 54 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

# React
- name: React - Install dependencies
run: yarn install
run: yarn install --frozen-lockfile
working-directory: ./client

- name: React - Build project
Expand All @@ -31,13 +31,13 @@ jobs:

# Node server
- name: Server - Install dependencies
run: yarn install
run: yarn install --frozen-lockfile --production
working-directory: ./server/src

# App
- name: Electron - Install dependencies
shell: bash
run: yarn install && yarn setdb
run: yarn install --frozen-lockfile && yarn setdb
working-directory: ./server
- name: Electron - Build app
run: yarn dist-mac
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:

# React
- name: React - Install dependencies
run: yarn install
run: yarn install --frozen-lockfile
working-directory: ./client

- name: React - Build project
Expand All @@ -74,13 +74,13 @@ jobs:

# Node server
- name: Server - Install dependencies
run: yarn install
run: yarn install --frozen-lockfile --production
working-directory: ./server/src

# App
- name: Electron - Install dependencies
shell: bash
run: yarn install && yarn setdb
run: yarn install --frozen-lockfile && yarn setdb
working-directory: ./server
- name: Electron - Build app
run: yarn dist-win
Expand Down Expand Up @@ -108,7 +108,7 @@ jobs:

# React
- name: React - Install dependencies
run: yarn install
run: yarn install --frozen-lockfile
working-directory: ./client

- name: React - Build project
Expand All @@ -117,7 +117,7 @@ jobs:

# Node server
- name: Server - Install dependencies
run: yarn install
run: yarn install --frozen-lockfile --production
working-directory: ./server/src

# App
Expand All @@ -136,3 +136,49 @@ jobs:
files: ./server/dist/ontime-linux.AppImage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish_docker:
runs-on: ubuntu-latest
env:
CI: ''

steps:
- uses: actions/checkout@v2
- name: Setup env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '14.x'

# React
- name: React - Install dependencies
run: yarn install
working-directory: ./client

- name: React - Build project
run: yarn build
working-directory: ./client

# Node server
- name: Server - Install dependencies
run: yarn install --frozen-lockfile --production
working-directory: ./server/src

# Login to docker
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# Build and push
- name: Build and push
working-directory: ./
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/ontime:${{ env.RELEASE_VERSION }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ yarn-error.log*
# working stuff
_SS/
db backup.json
server/src/data/db.json
server/src/preloaded-db/db.json
server/src/models/db.json
TODO.md
ontime-db/

# vscode stuff
.vscode/*
Expand Down
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM node:14-alpine

WORKDIR /app/server

# Prepare UI
COPY /client/build ../client/build

# Prepare Backend
COPY /server/src ./

# Export default ports Main - OSC IN
EXPOSE 4001/tcp 8888/udp
ENV NODE_ENV=production
ENV ONTIME_DATA=/server/

CMD ["yarn", "start:headless"]

# Build an run commandsN
# docker build -t getontime/ontime .
# docker run -p 4001:4001 -p 10.0.0.12:8888:8888/udp --mount type=bind,source="$(pwd)/ontime-db",target=/server/preloaded-db getontime/ontime
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ More documentation available [here](https://cpvalente.gitbook.io/ontime/)
- [x] Logging view
- [x] Edit anywhere: run ontime in your local network and use any machine to reach the editor page (
same as app)
- [x] Multi platform (available on Windows, MacOS and Linux)
- [x] [Headless run](#headless-run) (run server only, configure from a browser locally)

## Unopinionated

Expand Down Expand Up @@ -115,6 +117,29 @@ See [this repository](https://github.com/cpvalente/ontime-viewer-template) with
how to get you started and read the docs about
the [Websocket API](https://app.gitbook.com/s/-Mc0giSOToAhq0ROd0CR/control-and-feedback/websocket-api)

### Headless run️
You can self host and run ontime in a docker image, the run command should:
- expose the necessary ports (listen in Dockerfile)
- mount a local file to persist your data (in the example: ````$(pwd)/local-data````)
- the image name __getontime/ontime__

The docker image is in [available Docker Hub at getontime/ontime](https://hub.docker.com/r/getontime/ontime)
```bash
docker pull getontime/ontime
```

```bash
# Port 4001 - ontime server port
# Port 8888 - OSC input, bound to localhost IP Address
docker run -p 4001:4001 -p 127.0.0.1:8888:8888/udp --mount type=bind,source="$(pwd)/ontime-db",target=/server/preloaded-db getontime/ontime
```

or if running from the docker compose

```bash
docker-compose up
```

## Roadmap

### Continued development
Expand All @@ -126,7 +151,6 @@ friendly order unless there is user demand to bump any of them.
- [ ] Improvement with event component design
- [ ] New playback mode
for [cumulative time keeping](https://github.com/cpvalente/ontime/issues/100)
- [ ] Headless version (run server only anywhere, configure from a browser locally)
- [ ] Companion module
- [ ] Lower Third Manager
- [ ] Note only event
Expand Down
17 changes: 10 additions & 7 deletions client/src/app/api/apiConstants.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const NODE_PORT = 4001;
export const STATIC_PORT = 4001;
export const EVENT_TABLE = 'event';
export const ALIASES = 'aliases';
export const USERFIELDS = 'userFields';
Expand All @@ -8,15 +8,18 @@ export const OSC_SETTINGS = 'oscSettings';
export const APP_SETTINGS = 'appSettings';

/**
* @description finds server path given the current location
* @description finds server path given the current location, it
* @return {*}
*/
const calculateServer = () => {
return window.location.origin.replace(window.location.port, `${NODE_PORT}/`);
if (process.env?.NODE_ENV === 'development') {
return `http://localhost:${STATIC_PORT}`;
}
return window.location.origin;
};

export const serverURL = calculateServer();
export const eventURL = serverURL + EVENT_TABLE;
export const eventsURL = serverURL + EVENTS_TABLE;
export const playbackURL = `${serverURL}playback`;
export const ontimeURL = `${serverURL}ontime`;
export const eventURL = `${serverURL}/${EVENT_TABLE}`;
export const eventsURL = `${serverURL}/${EVENTS_TABLE}`;
export const playbackURL = `${serverURL}/playback`;
export const ontimeURL = `${serverURL}/ontime`;
4 changes: 3 additions & 1 deletion client/src/app/api/ontimeApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,9 @@ export const downloadEvents = async () => {
filename = headerLine.substring(startFileNameIndex, endFileNameIndex);
}

const url = window.URL.createObjectURL(new Blob([response.data]));
const url = window.URL.createObjectURL(
new Blob([response.data], { type: 'application/json' })
);
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', filename);
Expand Down