Skip to content

Commit 7444f70

Browse files
Node16 + stages for docker container (#3430)
* linter slim * dockerfile stages * revert worspace folder * node version update * super-linter readme update
1 parent 1bf12b7 commit 7444f70

4 files changed

Lines changed: 15 additions & 15 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"name": "Dev Container",
33
"build": {
44
"dockerfile": "../src/Dockerfile",
5-
"context": "../src/",
5+
"target": "base",
6+
"context": "../",
67
"args": {
7-
"IS_DEV_CONTAINER": "true",
88
"SKIPGC": "false"
99
}
1010
},
@@ -28,5 +28,6 @@
2828
"src/README.md"
2929
]
3030
}
31-
}
31+
},
32+
"onCreateCommand": "cd src && pip install -r requirements.txt && npm install"
3233
}

src/Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
ARG PYVER=3.8
2-
FROM python:${PYVER}
2+
FROM python:${PYVER} as base
33

44
# Enable unbuffered STDOUT logging
55
ENV PYTHONUNBUFFERED=1
66

7-
ARG NODEVER=12.x
7+
ARG NODEVER=16.x
88
RUN curl -sL https://deb.nodesource.com/setup_${NODEVER} | bash -
99

10-
RUN apt update && apt install -y \
11-
nodejs \
12-
&& rm -rf /var/lib/apt/lists/*
10+
RUN apt update && apt install -y nodejs && rm -rf /var/lib/apt/lists/* \
11+
&& /usr/local/bin/python -m pip install --upgrade pip
1312

1413
# Add Google Cloud SDK only if image is built with `--build-arg SKIPGC=false`
1514
ARG SKIPGC=true
1615
RUN $SKIPGC || (echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" > /etc/apt/sources.list.d/google-cloud-sdk.list \
1716
&& curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - \
1817
&& apt update && apt install -y google-cloud-sdk && rm -rf /var/lib/apt/lists/*)
1918

19+
FROM base
2020
WORKDIR /app
2121
COPY requirements.txt package*.json ./
2222
RUN pip install -r requirements.txt

src/README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Developing the Web Almanac
22

3-
The Web Almanac can be developed on macOS, Windows or Linux. It requires Node v12, Python v3.8 and pip to be installed. You can use Docker to avoid manually configuring the development environment.
3+
The Web Almanac can be developed on macOS, Windows or Linux. It requires Node v16, Python v3.8 and pip to be installed. You can use Docker to avoid manually configuring the development environment.
44
It can be quickly deployed as a development container in GitHub Codespaces to develop in cloud:
55
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/HTTPArchive/almanac.httparchive.org?quickstart=1)
66

@@ -14,7 +14,7 @@ An `.editorconfig` file exists for those using [EditorConfig](https://editorconf
1414

1515
Make sure you run the following commands from within the `src` directory by executing `cd src` first.
1616

17-
Make sure Python (3.8 or above), pip and NodeJS (v12 or above) are installed on your machine.
17+
Make sure Python (3.8 or above), pip and NodeJS (v16 or above) are installed on your machine.
1818

1919
1. If you don't have virtualenv, install it using pip.
2020

@@ -413,7 +413,6 @@ docker container run --rm -it -v "$PWD":/app webalmanac npm run pytest
413413
```
414414
docker container run --rm -it -v "$PWD":/app -v /app/node_modules -p 8080:8080 webalmanac bash
415415
root@[CID]:/app# python main.py
416-
^C
417416
root@[CID]:/app# npm run generate
418417
root@[CID]:/app# npm run pytest
419418
root@[CID]:/app# exit
@@ -430,11 +429,11 @@ docker image build --build-arg PYVER=3.8 --build-arg NODEVER=14.x --build-arg SK
430429
This will depend on your operating system but for MacOS/Linux this would be:
431430

432431
```
433-
docker container run -it --rm -v /app/node_modules -v "$PWD/..":/app -w /app/src --entrypoint=./tools/scripts/run_linter_locally.sh github/super-linter
432+
docker container run -it --rm -v /app/node_modules -v "$PWD/..":/app -w /app/src --entrypoint=./tools/scripts/run_linter_locally.sh github/super-linter:slim-latest
434433
```
435434

436435
And for Windows:
437436

438437
```
439-
docker container run --rm -v /app/node_modules -v %cd%\\..:/app -w /app/src --entrypoint=./tools/scripts/run_linter_locally.sh github/super-linter
438+
docker container run --rm -v /app/node_modules -v %cd%\\..:/app -w /app/src --entrypoint=./tools/scripts/run_linter_locally.sh github/super-linter:slim-latest
440439
```

src/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
"ebooks": "node ./tools/generate/generate_ebook_pdfs",
2222
"deploy": "./tools/scripts/deploy.sh",
2323
"lint": "run-script-os",
24-
"lint:darwin:linux": "docker container run -it --rm -v \"$PWD/..\":/app -w /app/src --entrypoint=./tools/scripts/run_linter_locally.sh github/super-linter",
25-
"lint:win32": "docker container run --rm -v \"%cd%\\..\":/app -w /app/src --entrypoint=./tools/scripts/run_linter_locally.sh github/super-linter",
24+
"lint:darwin:linux": "docker container run -it --rm -v \"$PWD/..\":/app -w /app/src --entrypoint=./tools/scripts/run_linter_locally.sh github/super-linter:slim-latest",
25+
"lint:win32": "docker container run --rm -v \"%cd%\\..\":/app -w /app/src --entrypoint=./tools/scripts/run_linter_locally.sh github/super-linter:slim-latest",
2626
"pytest": "pytest --cov server --cov-fail-under=100 --cov-report=term-missing -s",
2727
"stage": "./tools/scripts/deploy.sh -n",
2828
"start": "run-script-os",

0 commit comments

Comments
 (0)