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

feat: add docker containers with VNC access #208

Merged
merged 6 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,20 @@ sleep 30 # let the app actually start
docker-compose run materials-designer-test
```

To run tests in the container use default profile by not specifying it:

```bash
docker-compose up -d --build
```

For debugging purposes, Materials Designer and test container can be run interactively with access via VNC:

```bash
docker-compose --profile use-vnc up -d --build
```

Then connect to `vnc://localhost:5920` with a VNC client. The password is `123`. Make sure to have it installed on the system, when address is typed in the Chrome browser, the VNC prompt will appear.

### 3.5. Using Cove.js for local development

If need to link Cove.js into the app for local development, you need
Expand Down
20 changes: 20 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ services:
volumes:
- ./src/:/opt/app/src/
- ./entrypoint.sh:/opt/app/entrypoint.sh
profiles:
- ""
- use-vnc

# Meant to be used for CI/CD testing
materials-designer-test:
image: materials-designer-test:${IMAGE_TAG}
Expand All @@ -30,3 +34,19 @@ services:
volumes:
- ./tests/cypress:/opt/test/cypress
- ./entrypoint.sh:/opt/test/entrypoint.sh
profiles:
- ""

# For local testing with access via VNC
materials-designer-test-vnc:
image: materials-designer-test-vnc:${IMAGE_TAG}
build:
context: .
dockerfile: ./dockerfiles/app/test/Dockerfile-vnc
ports:
- 5920:5920
volumes:
- ./tests/cypress:/opt/test/cypress
- ./entrypoint-vnc.sh:/opt/test/entrypoint-vnc.sh
profiles:
- use-vnc
1 change: 0 additions & 1 deletion dockerfiles/app/test/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ WORKDIR /opt/test
COPY ./tests/package.json package.json
COPY ./tests/package-lock.json package-lock.json
COPY ./tests/cypress.config.ts cypress.config.ts
COPY ./tests/cypress cypress

RUN npm install

Expand Down
27 changes: 27 additions & 0 deletions dockerfiles/app/test/Dockerfile-vnc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# From https://hub.docker.com/r/cypress/browsers/tags
FROM materials-designer-test:latest

# Followed instructions from https://spin.atomicobject.com/cypress-running-docker-container/
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
curl \
libgtk2.0-0 \
libgtk-3-0 \
libgbm-dev \
libnotify-dev \
libgconf-2-4 \
libnss3 \
libxss1 \
libasound2 \
libxtst6 \
xauth \
xvfb \
x11vnc \
fluxbox

# Install Chrome
RUN curl https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -o /tmp/google-chrome.deb
RUN apt-get install -y /tmp/google-chrome.deb

ENV CYPRESS_BASE_URL=${CYPRESS_BASE_URL:-'http://host.docker.internal:3001'}

ENTRYPOINT ["/opt/test/entrypoint-vnc.sh"]
7 changes: 7 additions & 0 deletions entrypoint-vnc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# Run Xvfb, x11vnc and fluxbox and Cypress in a single CMD to ensure they're properly synchronized
export DISPLAY=":20"
Xvfb $DISPLAY -screen 0 1920x1080x16 &
x11vnc --passwd "123" -display $DISPLAY -N -forever -bg -o "/tmp/x11vnc.log" &
DISPLAY=$DISPLAY fluxbox -log /tmp/fluxbox.log &
DISPLAY=$DISPLAY cypress open /opt/tests/ --browser chrome
Loading