I am trying to create configuration for several environments with a single Dockerfile
, several docker-compose
files and several envoronment_v
Your docker-compose.yml should look like this:
version: '2'
services:
web:
build:
context: ./web
args:
REQUIREMENTS: "requirements_dev.txt"
Your Dockerfile should define the build-argument using ARG
like this:
FROM python:3.5
ENV PYTHONUNBUFFERED 1
ENV APP_ROOT /usr/src/app
ARG REQUIREMENTS
...
COPY $REQUIREMENTS $APP_ROOT/
RUN pip install -r $APP_ROOT/$REQUIREMENTS
I validated this and created a minified functional demo at Github:
https://github.com/jannikweichert/stackoverflow-41747843