Skip to content

Commit

Permalink
NodeJS in Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
covracer committed Nov 7, 2024
1 parent 4bcd09e commit baba85b
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 123 deletions.
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ repos:
- --write-changes
- id: dot-yaml
- id: gitignore-node-python
- id: hadolint
- id: includes-sh
- id: mailmap
- id: mypy
- id: prettier-write
exclude: package-lock.json
- id: ruff-check-fix
- id: ruff-format
- id: shellcheck
Expand Down
23 changes: 20 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,28 @@ FROM python:3.12
# TODO assert C.UTF8 and PYTHONUNBUFFERED are set correctly

WORKDIR /srv
RUN --mount=type=cache,target=/root/.cache pip install --upgrade pip-tools wheel

COPY includes.sh .
# hadolint ignore=SC2086
RUN --mount=type=cache,target=/var/cache/apt \
rm /etc/apt/apt.conf.d/docker-clean \
&& echo 'Binary::apt::APT::Keep-Downloaded-Packages "1";' > /etc/apt/apt.conf.d/99cache \
&& source includes.sh \
&& apt-get update \
&& apt-get install --no-install-recommends --quiet --quiet --yes nodejs $PACKAGES \
&& rm -rf /var/lib/apt/lists/*

COPY package-lock.json .
RUN --mount=type=cache,target=/root/.npm \
npm install --frozen-lockfile

COPY requirements.txt .
RUN --mount=type=cache,target=/root/.cache pip-sync
# hadolint ignore=DL3013,DL3042
RUN --mount=type=cache,target=/root/.cache \
pip install --disable-pip-version-check --upgrade "$(grep ^uv requirements.txt)" \
&& uv venv \
&& uv pip sync requirements.txt

# TODO multi-stage for faster development builds?
RUN mkdir -p static

COPY . .
Expand Down
5 changes: 2 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ services:
proxy:
image: cloudflare/cloudflared:2024.2.1

lab:
build: .
command: python -m manage shell_plus --allow-root
hub:
command: PATH="node_modules/.bin:$PATH" python -m jupyterhub
depends_on:
- postgres
environment:
Expand Down
1 change: 1 addition & 0 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# pre-commit
codespell
git+https://github.com/AleksaC/hadolint-py.git
mypy
ruff
shellcheck-py
Expand Down
Loading

0 comments on commit baba85b

Please sign in to comment.