Skip to content

Commit 428a260

Browse files
authored
Merge pull request #1703 from dodona-edu/fix/docker-web
2 parents 62c69d0 + fc7537c commit 428a260

File tree

11 files changed

+105
-65
lines changed

11 files changed

+105
-65
lines changed

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.tsbuildinfo
2+
dist/
3+
node_modules/
4+
*.iml

.github/workflows/ci-cd.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,8 +743,8 @@ jobs:
743743

744744
- name: Build the Dolos images
745745
run: |
746-
docker build docker/ -t ghcr.io/dodona-edu/dolos-cli:${{ steps.parse_tag.outputs.version }}
747-
docker build web/ -t ghcr.io/dodona-edu/dolos-web:${{ steps.parse_tag.outputs.version }}
746+
docker build . -f Dockerfile.cli -t ghcr.io/dodona-edu/dolos-cli:${{ steps.parse_tag.outputs.version }}
747+
docker build . -f Dockerfile.web -t ghcr.io/dodona-edu/dolos-web:${{ steps.parse_tag.outputs.version }}
748748
docker build api/ -t ghcr.io/dodona-edu/dolos-api:${{ steps.parse_tag.outputs.version }}
749749
750750
- name: Login to the container registry

.github/workflows/validation.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ jobs:
1515
uses: actions/checkout@v4
1616
with:
1717
submodules: true
18+
1819
- name: Setup Nix 📚
1920
uses: cachix/install-nix-action@v30
2021
with:
2122
github_access_token: ${{ secrets.GITHUB_TOKEN }}
23+
2224
- name: Build & check 🧪
2325
run: nix build -L '.?submodules=1#checks.x86_64-linux.dolos-cli'
24-
26+
2527
install-cli:
2628
name: "Install and run CLI on ${{ matrix.os }}"
2729
strategy:
@@ -93,17 +95,17 @@ jobs:
9395

9496
- name: Build WEB container
9597
run: |
96-
cd web
97-
docker build .
98+
docker build . -f Dockerfile.web
9899
99100
docker-cli:
100101
name: "Build dolos-cli docker container"
101102
runs-on: ubuntu-latest
102103
steps:
103104
- name: Checkout 🛎️
104105
uses: actions/checkout@v4
106+
with:
107+
submodules: true
105108

106-
- name: Build WEB container
109+
- name: Build CLI container
107110
run: |
108-
cd web
109-
docker build .
111+
docker build . -f Dockerfile.cli

Dockerfile.cli

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
FROM node:22.17.1-alpine3.22
2+
3+
WORKDIR /repo/
4+
5+
RUN apk add --no-cache curl python3 build-base
6+
7+
ADD package-lock.json package.json tsconfig.global.json /repo/
8+
9+
ADD core/ /repo/core
10+
11+
ADD parsers/ /repo/parsers
12+
13+
ADD lib/package.json lib/tsconfig.json lib/
14+
ADD lib/src /repo/lib/src
15+
16+
ADD web/index.d.ts web/index.js web/index.html web/package.json web/tsconfig.json web/vite.config.ts web/tsconfig.node.json /repo/web/
17+
ADD web/src /repo/web/src
18+
ADD web/public /repo/web/public
19+
20+
ADD cli/tsconfig.json cli/package.json /repo/cli/
21+
ADD cli/src /repo/cli/src
22+
ADD cli/typings /repo/cli/typings
23+
24+
RUN npm install
25+
26+
RUN apk del --no-cache python3 build-base
27+
28+
29+
RUN npm run --workspace core build
30+
RUN npm run --workspace web build
31+
RUN npm run --workspace cli build
32+
RUN npm --workspace cli link
33+
34+
WORKDIR /dolos
35+
USER node
36+
EXPOSE 3000/tcp
37+
ENTRYPOINT [ "dolos" ]

Dockerfile.web

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM node:22.17.1-alpine3.22
2+
3+
WORKDIR /repo/
4+
5+
RUN apk add --no-cache curl
6+
7+
ADD package-lock.json package.json tsconfig.global.json /repo/
8+
ADD core/ /repo/core
9+
10+
ADD web/index.d.ts web/index.js web/index.html web/package.json web/tsconfig.json web/vite.config.ts web/tsconfig.node.json /repo/web/
11+
ADD web/src /repo/web/src
12+
ADD web/public /repo/web/public
13+
14+
RUN npm install
15+
RUN npm run build --workspace core
16+
17+
ENV VITE_HOST=0.0.0.0
18+
ENV VITE_PORT=8080
19+
ENV VITE_MODE=server
20+
ENV DEFAULT_VITE_API_URL=http://localhost:3000
21+
EXPOSE 8080/tcp
22+
23+
WORKDIR /repo/web
24+
25+
RUN VITE_API_URL="$DEFAULT_VITE_API_URL" npm run build
26+
27+
28+
SHELL ["/bin/sh", "-c"]
29+
30+
CMD (test "$VITE_API_URL" == "$DEFAULT_VITE_API_URL" || npm run build) && npm run preview -- --host "$VITE_HOST" --port "$VITE_PORT" --strictPort

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,26 @@ This allows you to simultaneously develop the CLI, lib and the web project toget
9090

9191
Each component has its own build instructions in its own directory.
9292

93+
## Local installation using Docker
94+
95+
The latest Dolos version comes pre-installed in a Docker container image that is available from GitHub's container registry. Use the following command to pull the image:
96+
97+
```shell
98+
docker pull ghcr.io/dodona-edu/dolos-cli:latest
99+
```
100+
101+
Next, you can run an analysis with Dolos and start a web server to view the results using the following docker command:
102+
103+
```shell
104+
docker run --init --network host -v "$PWD:/dolos" dodona/dolos -l javascript -f web *.js
105+
```
106+
107+
The arguments passed to docker serve the following purpose:
108+
- `--init` will make sure stopping the container with Control-C works
109+
- `--network host` allows Dolos's webserver to bind to <http://localhost:3000>
110+
- `-v "$PWD:/dolos"` gives Dolos acces to your current directory
111+
112+
93113
## Components
94114

95115
- [CLI](https://github.com/dodona-edu/dolos/tree/main/cli): the command-line interface

docker-compose.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ services:
1919

2020
web:
2121
image: ghcr.io/dodona-edu/dolos-web
22-
# build: ./web/
22+
#build:
23+
# dockerfile: ./Dockerfile.web
24+
# context: .
2325
ports:
2426
# This renders to "host:port:8080", so traffic from the provided hosts on the specified
2527
# port is available to port 8080 inside the container. By default, this will be

docker/Dockerfile

Lines changed: 0 additions & 14 deletions
This file was deleted.

docker/README.md

Lines changed: 0 additions & 18 deletions
This file was deleted.

web/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,4 @@ You can change the following environment variables to alter how the UI works:
8080
- `VITE_API_URL` (default: http://localhost:3000) points to the Dolos API url
8181
- `VITE_MODE` changes the mode (`server` or empty)
8282

83-
Note that `VITE_HOST` and `VITE_PORT` can be used to change where the [Docker container](./Dockerfile) will be hosted.
83+
Note that `VITE_HOST` and `VITE_PORT` can be used to change where the [Docker container](../Dockerfile.web) will be hosted.

0 commit comments

Comments
 (0)