aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar scragly <[email protected]>2019-09-18 04:03:18 +1000
committerGravatar scragly <[email protected]>2019-09-18 05:22:17 +1000
commitb03685fb5c430cf836abd7f9b184a2a094f29819 (patch)
tree96cfcde6031d1afaef5ccf8547c9d1dba111299a
parentAdd test cases for `TypeError` fallbacks. (diff)
Refine Dockerfiles
-rw-r--r--docker-compose.yml2
-rw-r--r--docker/app/Dockerfile41
-rw-r--r--docker/app/Dockerfile.local49
-rw-r--r--docker/app/local.Dockerfile23
4 files changed, 31 insertions, 84 deletions
diff --git a/docker-compose.yml b/docker-compose.yml
index d415340b..0a8e6bcd 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -22,7 +22,7 @@ services:
web:
build:
context: .
- dockerfile: docker/app/Dockerfile.local
+ dockerfile: docker/app/local.Dockerfile
command: docker/app/scripts/migrate_and_serve.sh
ports:
- "127.0.0.1:8000:8000"
diff --git a/docker/app/Dockerfile b/docker/app/Dockerfile
index 903e7dc6..8378ceb9 100644
--- a/docker/app/Dockerfile
+++ b/docker/app/Dockerfile
@@ -5,46 +5,19 @@ STOPSIGNAL SIGQUIT
ARG EXTRAS=deploy
# Create a user.
-RUN adduser \
- --disabled-login \
- --no-create-home \
- --uid 1500 \
- pysite
+RUN useradd --system --shell /bin/false --uid 1500 pysite
# Install prerequisites needed to complete the dependency installation.
-RUN apt-get update -y \
- && \
- apt-get install --no-install-recommends -y \
- gcc \
- libc-dev \
- libpq-dev \
- git \
- && \
- apt-get clean \
- && \
- rm -rf /var/lib/apt/lists/*
+RUN install_packages git uwsgi
-# Set up the working directory.
+# Copy the project files into the working directory.
WORKDIR /app
-COPY Pipfile Pipfile.lock /app/
-
-# Pip install the stuff we'll need.
-RUN rm -r /opt/bitnami/python/lib/python3.*/site-packages/setuptools* && \
- pip install --no-cache-dir -U setuptools
-RUN python3 -m pip install pipenv \
- && python3 -m pipenv install --system --deploy \
- && pip install uwsgi==2.0.18
-
-# Copy everything into the docker environment.
COPY . .
-# RUN SECRET_KEY=placeholder DATABASE_URL=sqlite:// python3 manage.py collectstatic --no-input --clear --verbosity 0
-
-# Remove the prerequisites, dependency installation is now complete.
-RUN apt-get purge -y \
- gcc \
- libc-dev \
- libpq-dev
+# Update setuptools by removing egg first, add other dependencies
+RUN rm -r /opt/bitnami/python/lib/python3.*/site-packages/setuptools* && \
+ pip install --no-cache-dir -U setuptools pipenv
+RUN pipenv install --system --deploy
# Migrate, collect and start the app.
RUN chmod +x /app/docker/app/scripts/migrate.sh
diff --git a/docker/app/Dockerfile.local b/docker/app/Dockerfile.local
deleted file mode 100644
index c332c757..00000000
--- a/docker/app/Dockerfile.local
+++ /dev/null
@@ -1,49 +0,0 @@
-FROM bitnami/python:3.7-prod
-
-# I have no idea what this does.
-STOPSIGNAL SIGQUIT
-ARG EXTRAS=deploy
-
-# Create a user.
-RUN adduser \
- --disabled-login \
- --no-create-home \
- --uid 1500 \
- pysite
-
-# Install prerequisites needed to complete the dependency installation.
-RUN apt-get update -y \
- && \
- apt-get install --no-install-recommends -y \
- gcc \
- libc-dev \
- libpq-dev \
- git \
- && \
- apt-get clean \
- && \
- rm -rf /var/lib/apt/lists/*
-
-# Set up the working directory.
-WORKDIR /app
-COPY Pipfile Pipfile.lock /app/
-
-# Pip install the stuff we'll need.
-RUN rm -r /opt/bitnami/python/lib/python3.*/site-packages/setuptools* && \
- pip install --no-cache-dir -U setuptools
-RUN python3 -m pip install pipenv \
- && python3 -m pipenv install --system --deploy \
- && pip install uwsgi==2.0.18
-
-# Copy everything into the docker environment.
-COPY . .
-
-RUN SECRET_KEY=placeholder DATABASE_URL=sqlite:// python3 manage.py collectstatic --no-input --clear --verbosity 0
-
-# Remove the prerequisites, dependency installation is now complete.
-RUN apt-get purge -y \
- gcc \
- libc-dev \
- libpq-dev
-
-CMD ["uwsgi", "--ini", "docker/app/uwsgi.ini"]
diff --git a/docker/app/local.Dockerfile b/docker/app/local.Dockerfile
new file mode 100644
index 00000000..2edf4794
--- /dev/null
+++ b/docker/app/local.Dockerfile
@@ -0,0 +1,23 @@
+FROM bitnami/python:3.7-prod
+
+STOPSIGNAL SIGQUIT
+ARG EXTRAS=deploy
+
+# Create a user.
+RUN useradd --system --shell /bin/false --uid 1500 pysite
+
+# Install prerequisites needed to complete the dependency installation.
+RUN install_packages git uwsgi
+
+# Copy the project files into the working directory.
+WORKDIR /app
+COPY . .
+
+# Update setuptools by removing egg first, add other dependencies
+RUN rm -r /opt/bitnami/python/lib/python3.*/site-packages/setuptools* && \
+ pip install --no-cache-dir -U setuptools pipenv
+RUN pipenv install --system --deploy
+
+RUN SECRET_KEY=placeholder DATABASE_URL=sqlite:// python3 manage.py collectstatic --no-input --clear --verbosity 0
+
+CMD ["uwsgi", "--ini", "docker/app/uwsgi.ini"]