0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-22 17:24:15 +01:00
posthog/.devcontainer/Dockerfile

64 lines
2.4 KiB
Docker
Raw Normal View History

Reimplement codespaces support (#7234) * dev(codespaces): add "lean in" docker configuration for codespaces This changes creates a dedicated `docker-compose.yml` and `Dockerfile` for codespaces and doesn't attempt to have compatability with the existing docker config files. This is intentional and is designed to be a close to what codespaces would consider the ideal, so as to understand what great would look like. At the moment it doesn't do, but could: 1. install python and node packages in the image 2. push this image up to dockerhub 3. specify this image to be used for caching. There is a "cacheFrom" option in the [.devcontainer reference](https://code.visualstudio.com/docs/remote/devcontainerjson-reference) although I haven't checked how this works with using `docker-compose.yml`. Perhaps we just need to add the `image:` property to the `app` service :fingerscrossed: 4. specify default extensions and settings to be used. * Use python 3.9, not the latest python 3 codespaces supports * Add some basic python default settings and extensions * add github codespaces image build workflow * chore: update docker-compose cache from :cache tag * chore: use docker cache-to inline * add codespaces platform comment * temp run on branch * chore: fix flatforms format * chore: update qemu comment * chore: codespaces build use master image * chore: target x86_64 * chore: just use image for codespaces, don't try to build * add in python, node requirements * install node * install node * uncomment node deps install * use app network stack for all services * move .env to .dev.env and us in docker-compose * set WORKDIR to workspace * pin apt packages * pin versions, remove apt-key * add yarn cache clean * Fix hadolint warnings * make codespace build on master, or a PR with codespaces-build label * add missing && * dont bother with clickhouse install, its huge * dont be cute with the networks, just expose explicitly * fix network * create container zsh * correct .env path * point app to the clickhouse container * Also install saml deps * ignore .env again * libxml already installed * correct conditional workflow comment
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
#
# NOTE: I haven't tried to unify with `dev.Dockerfile` at this point. I want to
# understand what leaning into codespaces looks like first.
FROM mcr.microsoft.com/vscode/devcontainers/python:3.9-bullseye
WORKDIR /workspace
# Make sure all exit codes on pipes cause failures
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# Add in some useful dev cli tools
# hadolint ignore=DL3008
RUN apt-get update \
&& apt-get -y install --no-install-recommends \
# Add docker cli so we can do things like `docker logs`, and build images
"docker.io=20.*" \
Reimplement codespaces support (#7234) * dev(codespaces): add "lean in" docker configuration for codespaces This changes creates a dedicated `docker-compose.yml` and `Dockerfile` for codespaces and doesn't attempt to have compatability with the existing docker config files. This is intentional and is designed to be a close to what codespaces would consider the ideal, so as to understand what great would look like. At the moment it doesn't do, but could: 1. install python and node packages in the image 2. push this image up to dockerhub 3. specify this image to be used for caching. There is a "cacheFrom" option in the [.devcontainer reference](https://code.visualstudio.com/docs/remote/devcontainerjson-reference) although I haven't checked how this works with using `docker-compose.yml`. Perhaps we just need to add the `image:` property to the `app` service :fingerscrossed: 4. specify default extensions and settings to be used. * Use python 3.9, not the latest python 3 codespaces supports * Add some basic python default settings and extensions * add github codespaces image build workflow * chore: update docker-compose cache from :cache tag * chore: use docker cache-to inline * add codespaces platform comment * temp run on branch * chore: fix flatforms format * chore: update qemu comment * chore: codespaces build use master image * chore: target x86_64 * chore: just use image for codespaces, don't try to build * add in python, node requirements * install node * install node * uncomment node deps install * use app network stack for all services * move .env to .dev.env and us in docker-compose * set WORKDIR to workspace * pin apt packages * pin versions, remove apt-key * add yarn cache clean * Fix hadolint warnings * make codespace build on master, or a PR with codespaces-build label * add missing && * dont bother with clickhouse install, its huge * dont be cute with the networks, just expose explicitly * fix network * create container zsh * correct .env path * point app to the clickhouse container * Also install saml deps * ignore .env again * libxml already installed * correct conditional workflow comment
2021-11-23 09:34:51 +01:00
# Add in useful db debugging tools
"postgresql-client=13+*" \
Reimplement codespaces support (#7234) * dev(codespaces): add "lean in" docker configuration for codespaces This changes creates a dedicated `docker-compose.yml` and `Dockerfile` for codespaces and doesn't attempt to have compatability with the existing docker config files. This is intentional and is designed to be a close to what codespaces would consider the ideal, so as to understand what great would look like. At the moment it doesn't do, but could: 1. install python and node packages in the image 2. push this image up to dockerhub 3. specify this image to be used for caching. There is a "cacheFrom" option in the [.devcontainer reference](https://code.visualstudio.com/docs/remote/devcontainerjson-reference) although I haven't checked how this works with using `docker-compose.yml`. Perhaps we just need to add the `image:` property to the `app` service :fingerscrossed: 4. specify default extensions and settings to be used. * Use python 3.9, not the latest python 3 codespaces supports * Add some basic python default settings and extensions * add github codespaces image build workflow * chore: update docker-compose cache from :cache tag * chore: use docker cache-to inline * add codespaces platform comment * temp run on branch * chore: fix flatforms format * chore: update qemu comment * chore: codespaces build use master image * chore: target x86_64 * chore: just use image for codespaces, don't try to build * add in python, node requirements * install node * install node * uncomment node deps install * use app network stack for all services * move .env to .dev.env and us in docker-compose * set WORKDIR to workspace * pin apt packages * pin versions, remove apt-key * add yarn cache clean * Fix hadolint warnings * make codespace build on master, or a PR with codespaces-build label * add missing && * dont bother with clickhouse install, its huge * dont be cute with the networks, just expose explicitly * fix network * create container zsh * correct .env path * point app to the clickhouse container * Also install saml deps * ignore .env again * libxml already installed * correct conditional workflow comment
2021-11-23 09:34:51 +01:00
&& rm -rf /var/lib/apt/lists/*
# Install node
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
&& apt-get -y install --no-install-recommends "nodejs=16.*" \
Reimplement codespaces support (#7234) * dev(codespaces): add "lean in" docker configuration for codespaces This changes creates a dedicated `docker-compose.yml` and `Dockerfile` for codespaces and doesn't attempt to have compatability with the existing docker config files. This is intentional and is designed to be a close to what codespaces would consider the ideal, so as to understand what great would look like. At the moment it doesn't do, but could: 1. install python and node packages in the image 2. push this image up to dockerhub 3. specify this image to be used for caching. There is a "cacheFrom" option in the [.devcontainer reference](https://code.visualstudio.com/docs/remote/devcontainerjson-reference) although I haven't checked how this works with using `docker-compose.yml`. Perhaps we just need to add the `image:` property to the `app` service :fingerscrossed: 4. specify default extensions and settings to be used. * Use python 3.9, not the latest python 3 codespaces supports * Add some basic python default settings and extensions * add github codespaces image build workflow * chore: update docker-compose cache from :cache tag * chore: use docker cache-to inline * add codespaces platform comment * temp run on branch * chore: fix flatforms format * chore: update qemu comment * chore: codespaces build use master image * chore: target x86_64 * chore: just use image for codespaces, don't try to build * add in python, node requirements * install node * install node * uncomment node deps install * use app network stack for all services * move .env to .dev.env and us in docker-compose * set WORKDIR to workspace * pin apt packages * pin versions, remove apt-key * add yarn cache clean * Fix hadolint warnings * make codespace build on master, or a PR with codespaces-build label * add missing && * dont bother with clickhouse install, its huge * dont be cute with the networks, just expose explicitly * fix network * create container zsh * correct .env path * point app to the clickhouse container * Also install saml deps * ignore .env again * libxml already installed * correct conditional workflow comment
2021-11-23 09:34:51 +01:00
&& rm -rf /var/lib/apt/lists/*
# NOTE: the below is mostly just a copy of /dev.Dockerfile
# 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
# Compile and install Yarn 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 package.json yarn.lock ./
RUN yarn install --frozen-lockfile && \
yarn cache clean
COPY ./plugin-server/package.json ./plugin-server/yarn.lock ./plugin-server/
RUN yarn install --frozen-lockfile && \
yarn cache clean