-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Make the Dockerfile work and update requirements (#2)
Assorted getting-started fixes: * Made the Dockerfile successfully build with a working Python 3.9 environment * Added Anki dependency * Fixed some requirements problems that were preventing use of Django 4.2 * Fixed all pycodestyle and pylint failures * Got documentation builds working
- Loading branch information
Showing
23 changed files
with
510 additions
and
143 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,54 @@ | ||
FROM ubuntu:focal as app | ||
MAINTAINER [email protected] | ||
|
||
FROM ubuntu:focal as base | ||
|
||
# Packages installed: | ||
|
||
# language-pack-en locales; ubuntu locale support so that system utilities have a consistent | ||
# language and time zone. | ||
|
||
# python; ubuntu doesnt ship with python, so this is the python we will use to run the application | ||
|
||
# python3-pip; install pip to install application requirements.txt files | ||
# python3.9; version of python compatible with Anki | ||
|
||
# libmysqlclient-dev; to install header files needed to use native C implementation for | ||
# MySQL-python for performance gains. | ||
|
||
# libssl-dev; # mysqlclient wont install without this. | ||
|
||
# python3-dev; to install header files for python extensions; much wheel-building depends on this | ||
# make; needed to build the gevent wheel (unclear why a binary wheel isn't being found and used) | ||
|
||
# gcc; for compiling python extensions distributed with python packages like mysql-client | ||
# python3.9-dev; to install header files for python extensions; much wheel-building depends on this | ||
|
||
# If you add a package here please include a comment above describing what it is used for | ||
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -qy install --no-install-recommends \ | ||
language-pack-en locales \ | ||
python3.8 python3-dev python3-pip \ | ||
# The mysqlclient Python package has install-time dependencies | ||
libmysqlclient-dev libssl-dev pkg-config \ | ||
gcc | ||
# python3.9-venv; install Python 3.9 version of venv for creating a virtualenv with pip | ||
|
||
# gcc; for compiling python extensions distributed with python packages like mysql-client | ||
|
||
# unzip; for extracting the downloaded watchman binary release | ||
|
||
RUN pip install --upgrade pip setuptools | ||
# delete apt package lists because we do not need them inflating our image | ||
RUN rm -rf /var/lib/apt/lists/* | ||
# wget; for fetching a local copy of common_constraints.txt to edit until the Django 4.2 upgrade is complete | ||
|
||
RUN ln -s /usr/bin/python3 /usr/bin/python | ||
# If you add a package here please include a comment above describing what it is used for | ||
RUN apt-get update && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get -qy install --no-install-recommends software-properties-common && \ | ||
apt-add-repository -y ppa:deadsnakes/ppa && \ | ||
apt-get update && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get -qy install --no-install-recommends \ | ||
language-pack-en \ | ||
locales \ | ||
make \ | ||
python3.9 \ | ||
python3.9-dev \ | ||
python3.9-venv \ | ||
# The mysqlclient Python package has install-time dependencies | ||
libmysqlclient-dev \ | ||
libssl-dev \ | ||
pkg-config \ | ||
gcc \ | ||
unzip \ | ||
wget && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Create Python env | ||
ENV VIRTUAL_ENV=/edx/app/venvs/flashcards | ||
RUN python3.9 -m venv $VIRTUAL_ENV | ||
ENV PATH="$VIRTUAL_ENV/bin:$PATH" | ||
|
||
RUN locale-gen en_US.UTF-8 | ||
ENV LANG en_US.UTF-8 | ||
|
@@ -48,10 +63,13 @@ WORKDIR /edx/app/flashcards | |
|
||
# Copy the requirements explicitly even though we copy everything below | ||
# this prevents the image cache from busting unless the dependencies have changed. | ||
COPY requirements/pip.txt /edx/app/flashcards/requirements/pip.txt | ||
COPY requirements/production.txt /edx/app/flashcards/requirements/production.txt | ||
|
||
# Dependencies are installed as root so they cannot be modified by the application user. | ||
RUN pip install -r requirements/production.txt | ||
|
||
RUN pip install --no-cache-dir -r requirements/pip.txt | ||
RUN pip install --no-cache-dir -r requirements/production.txt | ||
|
||
RUN mkdir -p /edx/var/log | ||
|
||
|
@@ -65,3 +83,22 @@ CMD gunicorn --workers=2 --name flashcards -c /edx/app/flashcards/flashcards/doc | |
# This line is after the requirements so that changes to the code will not | ||
# bust the image cache | ||
COPY . /edx/app/flashcards | ||
|
||
# We don't switch back to the app user for devstack because we need devstack users to be | ||
# able to update requirements and generally run things as root. | ||
FROM base as dev | ||
USER root | ||
ENV DJANGO_SETTINGS_MODULE flashcards.settings.devstack | ||
|
||
# Install watchman | ||
RUN wget https://github.com/facebook/watchman/releases/download/v2023.10.23.00/watchman-v2023.10.23.00-linux.zip | ||
RUN unzip watchman-v2023.10.23.00-linux.zip | ||
RUN mkdir -p /usr/local/{bin,lib} /usr/local/var/run/watchman | ||
RUN cp watchman-v2023.10.23.00-linux/bin/* /usr/local/bin | ||
RUN cp watchman-v2023.10.23.00-linux/lib/* /usr/local/lib | ||
RUN chmod 755 /usr/local/bin/watchman | ||
RUN chmod 2777 /usr/local/var/run/watchman | ||
|
||
RUN pip install --no-cache-dir -r /edx/app/flashcards/requirements/dev.txt | ||
|
||
CMD while true; do python ./manage.py runserver 0.0.0.0:8491; sleep 2; done |
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
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
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
Oops, something went wrong.