Skip to content

Commit

Permalink
Update docker configuration for exercises (#3907)
Browse files Browse the repository at this point in the history
* Get exercises working in docker

    - Add new compose file for exercises
    - Update dockerfile to use debian bookworm and node 12
    - Listen on 0.0.0.0 instead of localhost

* Add additional clarity to troubleshooting steps
  • Loading branch information
TylerZeroMaster authored Jan 31, 2024
1 parent 514c710 commit 159415b
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 6 deletions.
17 changes: 14 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
FROM node:10.9-slim as builder
FROM debian:bookworm-slim as base

RUN apt-get update && apt-get install -y \
build-essential \
g++ \
gcc \
git \
python2.7 \
curl \
&& rm -rf /var/lib/apt/lists/*

RUN ln -s /usr/bin/python2.7 /usr/bin/python2
FROM base as builder
ENV NODE_VERSION=12.22.12
ENV NVM_DIR="/root/.nvm"
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash \
&& . $NVM_DIR/nvm.sh \
&& nvm install $NODE_VERSION \
&& nvm alias default $NODE_VERSION \
&& nvm use default \
&& npm install -g yarn

ENV NODE_PATH=$NVM_DIR/versions/node/v$NODE_VERSION/lib/node_modules
ENV PATH=$NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH

FROM builder as build
ARG PUBLIC_PATH
Expand Down
14 changes: 14 additions & 0 deletions docker-compose.exercises.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '3.5'
services:
build:
command: bash -c "if [ -z \"`ls -A node_modules`\" ]; then yarn; fi && yarn serve exercises"
build:
context: .
target: builder
working_dir: /code
environment:
- "OX_PROJECT_HOST=0.0.0.0"
volumes:
- .:/code:cached
ports:
- "8001:8001"
2 changes: 2 additions & 0 deletions docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ services:
context: .
target: builder
working_dir: /code
environment:
- "OX_PROJECT_HOST=0.0.0.0"
volumes:
- .:/code:cached
ports:
Expand Down
8 changes: 6 additions & 2 deletions docker-quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ the js files will be served at `http://localhost:8000`

the ui is available through the tutor-server project at `http://localhost:3001`

Something seem broken? See [Troubleshooting](#troubleshooting)

## Run Exercises frontend

``` bash
Expand All @@ -36,6 +38,8 @@ the js files will be served at `http://localhost:8001`

You will need to start the exercises backend independently

Something seem broken? See [Troubleshooting](#troubleshooting)

## node_modules

if you need to update node modules run:
Expand All @@ -53,5 +57,5 @@ docker-compose exec build <command>
## Troubleshooting

if you run into problems, try the following:
* rebuilding the build image with `docker-compose build`
* remove your node_modules directory
* rebuilding the build image with `docker-compose build` or `docker-compose -f <compose-file> build` (depending on your use case)
* remove your node_modules directory
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const config = {
quiet: false,
noInfo: false,
clientLogLevel: 'warning',
host: 'localhost',
host,
filename: '[name].js',
hot: !isCI,
liveReload: !isCI,
Expand Down

0 comments on commit 159415b

Please sign in to comment.