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

Sho/docker #86

Merged
merged 63 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
fcd4b91
init
Jul 17, 2020
16f21b3
update termination condition
Feb 22, 2021
4edb44e
added build of server component to image to reduce deployment time
Feb 22, 2021
ef7b812
Merge branch 'master' of ssh://git.rtsys.informatik.uni-kiel.de:7999/…
Feb 22, 2021
0be2943
merge
Feb 22, 2021
a528699
Dockerfile edited online with Bitbucket
saftigall Jul 6, 2021
f5bebb4
Update .gitlab-ci.yml file
soerendomroes May 3, 2022
1a01203
Test update .gitlab-ci.yml file
soerendomroes May 6, 2022
9de2cc7
Update .gitlab-ci.yml file
soerendomroes May 6, 2022
be546bf
Update .gitlab-ci.yml file
soerendomroes May 6, 2022
2a69ebe
Update .gitlab-ci.yml file
soerendomroes May 6, 2022
1c3c652
Update .gitlab-ci.yml file
soerendomroes May 6, 2022
d179e88
Update .gitlab-ci.yml file
soerendomroes May 6, 2022
57bf274
Update .gitlab-ci.yml file
soerendomroes May 6, 2022
ede2bd4
Update .gitlab-ci.yml file
soerendomroes May 6, 2022
a932362
Update .gitlab-ci.yml file
soerendomroes May 6, 2022
c676f2c
Update .gitlab-ci.yml file
soerendomroes May 6, 2022
91aad28
Update .gitlab-ci.yml file
soerendomroes May 6, 2022
9c66e57
Update .gitlab-ci.yml file
soerendomroes May 10, 2022
b3fb418
Update .gitlab-ci.yml file
soerendomroes May 10, 2022
781a6f3
Update .gitlab-ci.yml file
soerendomroes May 10, 2022
04987cb
Update .gitlab-ci.yml file
soerendomroes May 10, 2022
8591b7e
Update Dockerfile
saftigall May 30, 2022
dbc2655
Update Dockerfile
saftigall May 30, 2022
31ac53f
Update Dockerfile
saftigall May 30, 2022
cd1e840
Add docker-compose as crafted by arl.
shocau Apr 11, 2024
2e5eef0
Add simple healthcheck to running container.
shocau Apr 11, 2024
0407d49
Restart container automatically unless stopped.
shocau Apr 11, 2024
de0bac6
Limiting container resources to ½ CPU and 512m RAM.
shocau Apr 11, 2024
b2e534c
Shorten package install to only one command.
shocau Apr 11, 2024
a9643b9
Add minimal README.md.
shocau Apr 12, 2024
67758ce
Use Alpine base image as it was set in production.
shocau Apr 16, 2024
f2f45d1
Install curl used for health check into image.
shocau Apr 16, 2024
9386f7f
Drop hardcoded server IP to use image locally.
shocau Apr 16, 2024
c49a457
Merge branch 'master' of https://git.informatik.uni-kiel.de/ag-rtsys/…
shocau Jun 4, 2024
4c9bc17
Building Docker image locally.
shocau Jun 4, 2024
0069787
Running container need 640MB memory, now.
shocau Jun 4, 2024
598ee1c
No need to set docker-compose version any longer.
shocau Jun 4, 2024
0022c2b
Fix file extension to be ignored from Docker.
shocau Jun 4, 2024
7e5c2ba
Drop explicit container name.
shocau Jun 4, 2024
b58ba29
Rephrase doc section on container usage in README.
shocau Jun 4, 2024
114c2c9
Copied Docker workflow from master (#73)
shocau Jun 4, 2024
cf8f47f
Add version placeholder to get rid of git build dep.
shocau Jun 7, 2024
b0adaa3
Read version info to render from package.json.
shocau Jun 18, 2024
a37146c
Read commit hash from environment if available.
shocau Jun 18, 2024
124f4a0
Log environment during webpack build.
shocau Jun 18, 2024
9cd9306
Set UID of non-privileged container user via env.
shocau Jun 20, 2024
ade81d2
Specify chown user by name instead of UID.
shocau Jun 20, 2024
aa44e95
Pass group id as Docker build arg as well.
shocau Jun 21, 2024
93f55f7
Add comment regarding UID/GID usage.
shocau Jun 21, 2024
1bc31d5
Add argument for app home in Docker container.
shocau Jun 21, 2024
b3c8266
Bind mount local directory into container.
shocau Jun 24, 2024
0af3fe1
Dynamically assign host port w/ option to specify.
shocau Jun 25, 2024
00bc04c
Comment out all variables in .env.example.
shocau Jun 25, 2024
7012400
Ignore Docker env files from git and Docker itself.
shocau Jun 25, 2024
0d0650e
Don't bind work dir into container by default.
shocau Jun 25, 2024
48a94c2
More documentation on Docker usage.
shocau Jun 25, 2024
f74cefa
Reformat markdown, no functional changes.
shocau Jun 25, 2024
8fdb489
Matching UID/GID of 1st user of a Ubuntu system.
shocau Jun 25, 2024
6702560
Try tagging image as 'latest', too.
shocau Jun 25, 2024
b3efb91
Revert "Try tagging image as 'latest', too."
shocau Jun 25, 2024
d8939cc
Merge branch 'master' into sho/docker
shocau Jun 25, 2024
782cbc2
Delete .github/workflows/docker.yml
Eddykasp Jun 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.ash_history
.env
Dockerfile
docker-compose.yml
.git/ # some build steps require it to be a git repo
.gradle/
14 changes: 14 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copy this example to .env for usage and adapt to your needs.
# The .env file is automatically used by docker-compose command.

# Adapt to your UID:GID if not 1st user, which defaults to 1000:1000
# This is only necessary if you want to bind your work directory
# into a running container instance to actively develop this app.
#GID=1000
#UID=1000

# Which port to bind container app on host to. leave commented out
# for dynamically assigned high port which is the default except for
# production environment.
# Note that the value has to end with a colon for correct mapping syntax.
#HOST_PORT=8082:
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.ash_history
.env
.gradle/
14 changes: 8 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@ FROM alpine:3.19

LABEL authors="Arnd Plumhoff <[email protected]>, Sascha Hoppe <[email protected]>"

ARG ELKLIVE_UID=1002
ARG ELKLIVE_HOME=/elklive
ARG ELKLIVE_UID=1000
ARG ELKLIVE_GID=1000

RUN apk add --update --no-cache yarn git gradle curl

RUN adduser elklive -h /elklive -D -u ${ELKLIVE_UID}
RUN addgroup -g ${ELKLIVE_GID} elklive \
&& adduser elklive -h ${ELKLIVE_HOME} -D -u ${ELKLIVE_UID} -G elklive

USER elklive

RUN git clone https://github.com/kieler/elk-live --depth=1 /elklive
COPY --chown=elklive:elklive . ${ELKLIVE_HOME}

WORKDIR "/elklive/client"
RUN yarn install && yarn run build
RUN cd ${ELKLIVE_HOME}/client && yarn install && yarn run build

WORKDIR "/elklive/server"
WORKDIR "${ELKLIVE_HOME}/server"
RUN ./gradlew build

EXPOSE 8080
Expand Down
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ Uses:

[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/OpenKieler/elkgraph-web)

The easiest way to start working with this project is to open it in [gitpod.io](https://gitpod.io) with the button above. If you would like to compile and run it on your own machine, follow the instructions below.
The easiest way to start working with this project is to open it in
[gitpod.io](https://gitpod.io) with the button above. If you would like to
compile and run it on your own machine, follow the instructions below.

Prerequisites: [yarn](https://yarnpkg.com/), [Java](https://jdk.java.net)

Expand All @@ -29,5 +31,29 @@ cd ../server

Then point your web browser to `http://localhost:8080/`

This project provides a container based runtime environment for the
[elk-live](https://github.com/kieler/elk-live) project.

## Usage

Build and/or run image with [Docker](https://www.docker.com). You can start
container on pre-built image with `docker run ghcr.io/kieler/elk-live:master`.

### Local image build

You can also build an container image locally by using the provided Dockerfile
or, more comfortable, using docker-compose.yml with `docker-compose up --build`
and `docker build`, respectively. This way you can locally adapt the runtime
environment to your needs and even develop actively with nicely separated
build- and runtime dependencies.

To easily get started with a locally built image, follow the steps below

```terminal
cp .env.example .env
vi .env # adapt settings via provided environment
docker-compose up --build
```

## Hosting
If you would like to host elk-live yourself you can use the automatically built [Docker container](https://github.com/kieler/elk-live/pkgs/container/elk-live). There is also an [example configuration](https://github.com/kieler/elk-live/blob/master/docker-compose.yml) for Docker Compose.
If you would like to host elk-live yourself you can use the automatically built [Docker container](https://github.com/kieler/elk-live/pkgs/container/elk-live). There is also an [example configuration](https://github.com/kieler/elk-live/blob/master/docker-compose.yml) for Docker Compose.
19 changes: 13 additions & 6 deletions client/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ const childProcess = require('child_process');
const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
const fs = require('fs');
const globby = require('globby');
const package = require('./package.json')

module.exports = async function (env) {
if (!env) {
env = {}
}
console.log("environment: ", env);
console.log("environment: ", process.env);

const buildRoot = path.resolve(__dirname, 'lib');
const appRoot = path.resolve(__dirname, 'app');
Expand All @@ -40,7 +43,11 @@ module.exports = async function (env) {
const elkWorkerPath9 = 'node_modules/elkjs-9/lib/elk-worker.min.js';
const elkWorkerPathLatest = 'node_modules/elkjs-latest/lib/elk-worker.min.js';
const elkWorkerPathNext = 'node_modules/elkjs-next/lib/elk-worker.min.js';
const currentGitCommit = childProcess.execSync('git rev-parse --short HEAD').toString().trim();
currentVersion = package.version;
if (process.env.GITHUB_SHA) {
currentVersion += '-' + process.env.GITHUB_SHA;
}
console.log("Building ELK-Graph Web version " + currentVersion);

const javaElkVersions = [ 'snapshot' ]; // latest snapshot/nightly at the time of building
// Query released ELK versions using maven's REST API
Expand Down Expand Up @@ -128,35 +135,35 @@ module.exports = async function (env) {
template: 'src/elkgraph/elkgraph_template.html',
inject: false,
layoutOptionVersions: javaElkVersionsOptions,
currentGitCommit: currentGitCommit,
currentGitCommit: currentVersion,
}),
new HtmlWebpackPlugin({
filename: 'examples.html',
template: 'src/examples/examples_template.html',
inject: false,
layoutOptionVersions: javaElkVersionsOptions,
currentGitCommit: currentGitCommit,
currentGitCommit: currentVersion,
}),
new HtmlWebpackPlugin({
filename: 'json.html',
template: 'src/json/json_template.html',
inject: false,
nextVersion: elkjsNext.version,
latestVersion: elkjsLatest.version,
currentGitCommit: currentGitCommit,
currentGitCommit: currentVersion,
}),
new HtmlWebpackPlugin({
filename: 'models.html',
template: 'src/models/models_template.html',
inject: false,
elkjsVersion: elkjsLatest.version,
currentGitCommit: currentGitCommit,
currentGitCommit: currentVersion,
}),
new HtmlWebpackPlugin({
filename: 'conversion.html',
template: 'src/conversion/conversion_template.html',
inject: false,
currentGitCommit: currentGitCommit,
currentGitCommit: currentVersion,
}),
new CopyWebpackPlugin([{
from: monacoEditorPath,
Expand Down
16 changes: 10 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
version: "2"

services:
elkweb:
container_name: elkweb
image: ghcr.io/kieler/elk-live:master
build:
context: .
args:
- ELKLIVE_UID=${UID:-1000}
- ELKLIVE_GID=${GID:-1000}
ports:
- 8082:8080
- ${HOST_PORT}8080
# Activate to bind work dir into container, e.g. for local development
# volumes:
# - .:/elklive
restart: unless-stopped
cpus: 0.5
mem_limit: 536870912
mem_limit: 1024m
healthcheck:
test: curl --fail http://localhost:8080 || exit 1
interval: 60s
Expand Down
Loading