I'm developing a Python project using VSCode Dev Containers. Until now, to build the container I'm developing on, I used the Dockerfile located in the project root, which the same one used for production, so that my development environment fully matched the deployed environment. This Dockerfile performs all the pip install steps.
Additional development-only tools (VSCode extensions, notebooks, etc.) were handled through devcontainer.json.
Recently, after installing Cato on my Mac (to connect to an internal PyPI hub), the pip install phase inside the container stopped working. Our IT team told me I need to add a certificate (cato-ca.crt) into the container, using the following commands:
RUN mkdir /usr/local/share/ca-certificates/cato-ca
COPY .devcontainer/cato-ca.crt /usr/local/share/ca-certificates/cato-ca/cato-ca.crt
RUN chmod 644 /usr/local/share/ca-certificates/cato-ca/cato-ca.crt && update-ca-certificates
These steps cannot be added to the production build, because the CI/CD environment doesn’t have (and shouldn’t have) this certificate. Because of this, I had to create a second Dockerfile used only for the Dev Container.
Question:
Is there a way to keep a single Dockerfile and conditionally include these certificate-installation commands only when building the Dev Container (and before pip install runs)?