Skip to content

Commit

Permalink
Get exercises working in docker
Browse files Browse the repository at this point in the history
- Add new compose file for exercises
- Update dockerfile to use node 18
- Listen on 0.0.0.0 instead of localhost
- Use node-sass 9
- Fix build and serve commands
  • Loading branch information
TylerZeroMaster committed Dec 19, 2023
1 parent 5f30239 commit 4597861
Show file tree
Hide file tree
Showing 8 changed files with 558 additions and 149 deletions.
21 changes: 17 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
FROM node:10.9-slim as builder
FROM node:18-slim as base

RUN apt-get update && apt-get install -y \
build-essential \
g++ \
gcc \
git \
python2.7 \
&& rm -rf /var/lib/apt/lists/*
curl \
# Additional packages required by python build
zlib1g \
zlib1g-dev \
libssl-dev \
libbz2-dev \
libsqlite3-dev \
&& rm -rf /var/lib/apt/lists/*

FROM base as builder

ENV PATH=/root/.pyenv/bin:$PATH
RUN curl https://pyenv.run | bash \
&& eval "$(pyenv virtualenv-init -)" \
&& pyenv install 2.7 \
&& ln -s /root/.pyenv/shims/python /usr/bin/python

RUN ln -s /usr/bin/python2.7 /usr/bin/python2

FROM builder as build
ARG PUBLIC_PATH
Expand Down
2 changes: 1 addition & 1 deletion bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if [ "$(version "$npm_version")" -lt "$(version "$required_version")" ]; then
fi

[ -d $OX_PROJECT/dist ] && rm -r $OX_PROJECT/dist
$(npm bin)/webpack --config webpack.config.js
NODE_OPTIONS="--openssl-legacy-provider" npx webpack --config webpack.config.js

# we're done unless the "archive" flag from the ansible build is set
if [ "$2" != "archive" ]; then
Expand Down
2 changes: 1 addition & 1 deletion bin/serve
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ echo Serving: $OX_PROJECT
if [ x$2 == x"standalone" ]; then
node tutor/specs/acceptance/server/index.js
else
node --max_old_space_size=2048 $(npm bin)/webpack-dev-server --debug --progress --config webpack.config.js
NODE_OPTIONS="--openssl-legacy-provider --max_old_space_size=2048" npx webpack-dev-server --debug --progress --config webpack.config.js
fi
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"
4 changes: 3 additions & 1 deletion docker-compose.override.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
version: '3.5'
services:
build:
command: bash -c "if [ -z \"`ls -A node_modules`\" ]; then yarn; fi && yarn serve tutor"
command: bash -c "if [ -z \"`ls -A node_modules`\" ]; then yarn; fi && yarn run serve tutor"
build:
context: .
target: builder
working_dir: /code
environment:
- "OX_PROJECT_HOST=0.0.0.0"
volumes:
- .:/code:cached
ports:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
"jsdom": "^16.5.0",
"json-server": "^0.15.0",
"lighthouse": "^5.2.0",
"node-sass": "^7.0.0",
"node-sass": "^9.0.0",
"object-factory-bot": "0.8.2",
"pixelmatch": "^5.0.2",
"pngjs": "^3.4.0",
Expand Down
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
Loading

0 comments on commit 4597861

Please sign in to comment.