-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup and simplify configuration/localdev
- Loading branch information
1 parent
88d1597
commit 4010aef
Showing
11 changed files
with
107 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM python:3.9.6 | ||
FROM python:3.9.6 as base | ||
LABEL maintainer "ODL DevOps <[email protected]>" | ||
|
||
# Add package files, install updated node and pip | ||
|
@@ -13,7 +13,7 @@ RUN apt-get install -y $(grep -vE "^\s*#" apt.txt | tr "\n" " ") | |
RUN curl --silent --location https://bootstrap.pypa.io/get-pip.py | python3 - | ||
|
||
# Add, and run as, non-root user. | ||
RUN mkdir /src | ||
RUN mkdir /app | ||
RUN adduser --disabled-password --gecos "" mitodl | ||
RUN mkdir /var/media && chown -R mitodl:mitodl /var/media | ||
|
||
|
@@ -23,16 +23,27 @@ COPY test_requirements.txt /tmp/test_requirements.txt | |
RUN pip install -r requirements.txt -r test_requirements.txt | ||
|
||
# Add project | ||
COPY . /src | ||
WORKDIR /src | ||
RUN chown -R mitodl:mitodl /src | ||
COPY . /app | ||
WORKDIR /app | ||
RUN chown -R mitodl:mitodl /app | ||
|
||
RUN apt-get clean && apt-get purge | ||
USER mitodl | ||
|
||
# Set pip cache folder, as it is breaking pip when it is on a shared volume | ||
ENV XDG_CACHE_HOME /tmp/.cache | ||
|
||
FROM base as django | ||
|
||
USER mitodl | ||
|
||
FROM base as django-server | ||
|
||
EXPOSE 8013 | ||
ENV PORT 8013 | ||
CMD uwsgi uwsgi.ini | ||
|
||
FROM base as jupyter-notebook | ||
|
||
RUN pip install --force-reinstall jupyter | ||
|
||
USER mitodl |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/sh | ||
# Based on https://github.com/nginxinc/docker-nginx/blob/6f0396c1e06837672698bc97865ffcea9dc841d5/mainline/debian/20-envsubst-on-templates.sh | ||
|
||
set -e | ||
|
||
ME=$(basename $0) | ||
|
||
auto_erb_build() { | ||
local template="/etc/nginx/templates/nginx.conf.erb" | ||
local output_path="/etc/nginx/nginx.conf" | ||
|
||
echo >&3 "$ME: Running erb on $template to $output_path" | ||
erb "$template" > "$output_path" | ||
} | ||
|
||
auto_erb_build | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# NOTE: this dockerfile is primarilty for local development only | ||
# it's primary purpose is to emulate heroku-buildpack-nginx's | ||
# functionality that compiles config/nginx.conf.erb | ||
# See https://github.com/heroku/heroku-buildpack-nginx/blob/fefac6c569f28182b3459cb8e34b8ccafc403fde/bin/start-nginx | ||
FROM nginx:1.21 | ||
|
||
# Logs are configured to a relatic path under /etc/nginx | ||
# but the container expects /var/log | ||
RUN mkdir -p /etc/nginx/logs && ln -sf /var/log/nginx /etc/nginx/logs/ | ||
|
||
# erb unfortunately needs a whole ruby install | ||
RUN apt-get update && apt-get install -y ruby | ||
|
||
# this gets run automatically by the nginx container's entrypoint | ||
COPY 20-compile-nginx-conf-erb.sh /docker-entrypoint.d | ||
|
||
# NOTE: this removes the args "-g daemon off" because nginx is impolite | ||
# and treats a cli flag and a config flag as duplicate: | ||
# | ||
# nginx: [emerg] "daemon" directive is duplicate in /etc/nginx/nginx.conf:3 | ||
# | ||
CMD ["nginx"] |