2024-06-21 18:45:42 +02:00
|
|
|
|
# hadolint global ignore=DL3004
|
|
|
|
|
|
|
|
|
|
# hadolint doesn't like changes to this file, but it is only used for local dev
|
|
|
|
|
|
2021-11-23 09:34:51 +01:00
|
|
|
|
# Defines the environment you're dropped into with codespaces
|
|
|
|
|
# I've take
|
|
|
|
|
# https://github.com/microsoft/vscode-dev-containers/blob/main/containers/python-3/.devcontainer/Dockerfile
|
|
|
|
|
# and surrounding files as inspiration. I'm extending their image rather than
|
|
|
|
|
# building from e.g. the official python docker images as there appears to be
|
|
|
|
|
# quite a bit done as part of the vscode images, presumably to make the
|
|
|
|
|
# experience as rich as possible. Perhaps later down the line it might be worth
|
|
|
|
|
# rolling our own
|
|
|
|
|
#
|
2024-06-21 18:45:42 +02:00
|
|
|
|
FROM mcr.microsoft.com/vscode/devcontainers/python:3.11-bullseye
|
2021-11-23 09:34:51 +01:00
|
|
|
|
|
|
|
|
|
# Make sure all exit codes on pipes cause failures
|
|
|
|
|
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
|
|
|
|
|
2022-05-05 16:05:56 +02:00
|
|
|
|
# Set up docker in docker as per
|
2022-06-28 13:50:57 +02:00
|
|
|
|
# https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/docker-in-docker.md
|
2022-05-05 16:05:56 +02:00
|
|
|
|
COPY .devcontainer/library-scripts /tmp/library-scripts
|
|
|
|
|
|
|
|
|
|
ENV DOCKER_BUILDKIT=1
|
|
|
|
|
RUN /tmp/library-scripts/docker-in-docker-debian.sh
|
|
|
|
|
ENTRYPOINT ["/usr/local/share/docker-init.sh"]
|
|
|
|
|
VOLUME [ "/var/lib/docker" ]
|
|
|
|
|
CMD ["sleep", "infinity"]
|
|
|
|
|
|
2021-11-23 09:34:51 +01:00
|
|
|
|
# Add in some useful dev cli tools
|
|
|
|
|
# hadolint ignore=DL3008
|
|
|
|
|
RUN apt-get update \
|
|
|
|
|
&& apt-get -y install --no-install-recommends \
|
|
|
|
|
# Add in useful db debugging tools
|
2022-01-28 12:23:17 +01:00
|
|
|
|
"postgresql-client=13+*" \
|
2023-04-13 11:58:46 +02:00
|
|
|
|
# needed for posthog to run
|
|
|
|
|
netcat brotli curl \
|
2021-11-23 09:34:51 +01:00
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
2023-04-13 11:58:46 +02:00
|
|
|
|
RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
|
|
|
|
|
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
|
|
|
|
|
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
|
|
|
|
|
&& sudo apt update \
|
|
|
|
|
&& sudo apt install gh -y
|
|
|
|
|
|
2022-12-12 15:02:33 +01:00
|
|
|
|
# Install node via NVM (https://github.com/nvm-sh/nvm)
|
|
|
|
|
ARG NODE_VERSION="18"
|
2022-05-05 16:05:56 +02:00
|
|
|
|
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
|
2021-11-23 09:34:51 +01:00
|
|
|
|
|
2023-03-20 22:27:19 +01:00
|
|
|
|
# install pnpm globally, this container doesn't expose a supported shell to the pnpm installer
|
|
|
|
|
# so `RUN curl -fsSL https://get.pnpm.io/install.sh | sh -` fails
|
|
|
|
|
# see https://github.com/pnpm/pnpm/issues/4495
|
2024-05-03 13:31:41 +02:00
|
|
|
|
RUN corepack enable && pnpm --version \
|
2023-03-20 22:27:19 +01:00
|
|
|
|
&& SHELL=bash pnpm setup \
|
|
|
|
|
&& source /root/.bashrc
|
2023-03-01 13:03:54 +01:00
|
|
|
|
|
2022-05-05 16:05:56 +02:00
|
|
|
|
WORKDIR /workspace
|
|
|
|
|
|
2021-11-23 09:34:51 +01:00
|
|
|
|
# Compile and install Python dependencies.
|
|
|
|
|
#
|
|
|
|
|
# Notes:
|
|
|
|
|
#
|
|
|
|
|
# - we explicitly COPY the files so that we don't need to rebuild
|
|
|
|
|
# the container every time a dependency changes
|
|
|
|
|
#
|
|
|
|
|
# - we need few additional OS packages for this. Let's install
|
|
|
|
|
# and then uninstall them when the compilation is completed.
|
|
|
|
|
COPY requirements.txt requirements-dev.txt ./
|
|
|
|
|
RUN pip install -r requirements-dev.txt --compile --no-cache-dir && \
|
|
|
|
|
pip install -r requirements.txt --compile --no-cache-dir
|