Skip to content
This repository has been archived by the owner on Dec 21, 2018. It is now read-only.

Commit

Permalink
Switch to python-3.6-alpine base image
Browse files Browse the repository at this point in the history
* Slimmer and easier to use base image
* Based on official Python image so most up to date
* Remove supervisor so no longer also need Python 2.7
* Remove dependency on libmemcache since non longer installing pylibmc
  • Loading branch information
pmac committed May 9, 2017
1 parent 7070ace commit ee5f6a5
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 44 deletions.
8 changes: 4 additions & 4 deletions Makefile
Expand Up @@ -41,14 +41,14 @@ run: .docker-build
${DOCKERCOMPOSE} up web

shell: .docker-build
${DOCKERCOMPOSE} run web python3 manage.py shell
${DOCKERCOMPOSE} run web python manage.py shell

restore-db: .docker-build
-${DOCKERCOMPOSE} run web dropdb -h db -U postgres -w postgres
${DOCKERCOMPOSE} run web createdb -h db -U postgres -w postgres
-${DOCKERCOMPOSE} run web pg_restore -d "postgres://postgres@db/postgres" < ${PG_DUMP_FILE}
${DOCKERCOMPOSE} run web python3 manage.py migrate --fake-initial
${DOCKERCOMPOSE} run web python3 manage.py createsuperuser
${DOCKERCOMPOSE} run web python manage.py migrate --fake-initial
${DOCKERCOMPOSE} run web python manage.py createsuperuser

clean:
# python related things
Expand Down Expand Up @@ -80,7 +80,7 @@ test-image: .docker-build
${DOCKERCOMPOSE} run test-image

test-smoketest: .docker-build
${DOCKERCOMPOSE} run -e SERVER_URL=${SERVER_URL} test python3 tests/smoketest.py
${DOCKERCOMPOSE} run -e SERVER_URL=${SERVER_URL} test python tests/smoketest.py

docs: .docker-build
${DOCKERCOMPOSE} run web $(MAKE) -C docs/ clean
Expand Down
2 changes: 1 addition & 1 deletion bin/phb-manage.sh
Expand Up @@ -17,4 +17,4 @@ export DATABASE_URL=sqlite://
# export AUTH0_DOMAIN=foo
# export AUTH0_CALLBACK_URL=foo

python3 manage.py $@
python manage.py $@
2 changes: 1 addition & 1 deletion bin/run-common.sh
Expand Up @@ -3,4 +3,4 @@
# Migrate the db
# --fake-initial will fake the migration only if the table
# already exists. Needed for the initial migration in prod.
python3 manage.py migrate --noinput --fake-initial
python manage.py migrate --noinput --fake-initial
2 changes: 1 addition & 1 deletion bin/run-dev.sh
Expand Up @@ -2,4 +2,4 @@

urlwait
./bin/run-common.sh
exec python3 manage.py runserver 0.0.0.0:8000
exec python manage.py runserver 0.0.0.0:8000
2 changes: 1 addition & 1 deletion bin/run-supervisor.sh → bin/run.sh
Expand Up @@ -2,4 +2,4 @@

export SERVER_MODE="${1:-dev}"
export LOG_LEVEL="${LOG_LEVEL:-info}"
exec supervisord -c etc/supervisord.conf
exec "bin/run-${SERVER_MODE}.sh"
2 changes: 1 addition & 1 deletion bin/standup-cmd
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python

"""
This is the command-line script for standups. Makes testing easier.
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Expand Up @@ -18,7 +18,7 @@ services:
- DEBUG=True
- ALLOWED_HOSTS=localhost,127.0.0.1,web
- SECRET_KEY=itsasekrit
command: ./bin/run-supervisor.sh dev
command: ./bin/run.sh dev

# run the site in a prod-like environment
prod:
Expand All @@ -34,7 +34,7 @@ services:
- DEBUG=False
- ALLOWED_HOSTS=localhost,127.0.0.1
- SECRET_KEY=itsasekrit
command: ./bin/run-supervisor.sh prod
command: ./bin/run.sh prod

# run the tests
test:
Expand Down
24 changes: 7 additions & 17 deletions docker/standup_base
@@ -1,11 +1,8 @@
FROM quay.io/mozmar/base

# Set Python-related environment variables to reduce annoying-ness
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
ENV LANG=C.UTF-8
ENV PATH=/usr/local/lib/node_modules/standup/node_modules/.bin:$PATH
FROM mozmeao/base:python-3.6-alpine

RUN apk add --update --no-cache nodejs postgresql-dev

ENV PATH=/usr/lib/node_modules/standup/node_modules/.bin:$PATH
ENV PIPELINE_LESS_BINARY=lessc
ENV PIPELINE_UGLIFYJS_BINARY=uglifyjs
ENV PIPELINE_CLEANCSS_BINARY=cleancss
Expand All @@ -14,22 +11,15 @@ ENV PIPELINE_CLEANCSS_BINARY=cleancss
ENV DJANGO_SETTINGS_MODULE standup.settings

EXPOSE 8000
CMD ["./bin/run-supervisor.sh", "prod"]
CMD ["./bin/run.sh", "prod"]
WORKDIR /app
RUN update-alternatives --install /bin/sh sh /bin/bash 10

RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential python3-{dev,pip,setuptools} libmemcached-dev nodejs-legacy \
npm gettext libpq-dev postgresql-client supervisor && \
rm -rf /var/lib/apt/lists/*

# First copy requirements.txt so we can take advantage of docker caching.
COPY package.json ./
RUN npm install -g

COPY requirements.txt ./
RUN pip3 install --require-hashes --no-cache-dir -r requirements.txt
RUN pip install --require-hashes --no-cache-dir -r requirements.txt

COPY . /app

Expand Down
4 changes: 2 additions & 2 deletions docker/standup_dev
@@ -1,6 +1,6 @@
FROM local/standup_base

COPY requirements-dev.txt ./
RUN pip3 install --require-hashes --no-cache-dir -r requirements-dev.txt
RUN pip install --require-hashes --no-cache-dir -r requirements-dev.txt

CMD ["./bin/run-supervisor.sh", "dev"]
CMD ["./bin/run.sh", "dev"]
13 changes: 0 additions & 13 deletions etc/supervisord.conf

This file was deleted.

2 changes: 1 addition & 1 deletion manage.py
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python
import os
import sys

Expand Down

0 comments on commit ee5f6a5

Please sign in to comment.