Skip to content

Commit

Permalink
Add Dockerfile ARG for controlling Python deps (#1548)
Browse files Browse the repository at this point in the history
Fixes #1530
  • Loading branch information
robhudson authored and wlach committed Feb 28, 2019
1 parent f212bd4 commit 8052e09
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ jobs:
steps:
- checkout
- setup_remote_docker
- restore_cache:
key: v1-{{.Branch}}
# We are not using the cached docker file here b/c we want the production
# build to use only the required Python files.
- run:
name: Restore Docker image cache
command: docker load -i /tmp/docker.tar
name: Build Docker image
command: docker build -t app:build --build-arg PIP_FILE=build.txt .
- run:
name: Push image to Docker Hub
command: |
Expand Down
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
FROM python:3.7.2-alpine

# Default to building for local development.
# Override with `--build-arg PIP_FILE=build.txt` to build for production.
ARG PIP_FILE=all.txt

EXPOSE 8000

WORKDIR /app
Expand All @@ -23,7 +27,7 @@ COPY requirements/*.txt /tmp/requirements/
# Switch to /tmp to install dependencies outside home dir
WORKDIR /tmp
# TODO: Consider a way to install only the "build.txt" deps for production.
RUN pip install --require-hashes --no-cache-dir -r requirements/all.txt
RUN pip install --require-hashes --no-cache-dir -r requirements/$PIP_FILE

WORKDIR /app
COPY . /app
Expand Down

0 comments on commit 8052e09

Please sign in to comment.