Skip to content
This repository was archived by the owner on Apr 14, 2026. It is now read-only.

Commit d5992e3

Browse files
authored
Merge pull request #39 from stacken/restructure
Restructure
2 parents be115c6 + 1e650d5 commit d5992e3

72 files changed

Lines changed: 65 additions & 69 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/black.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ jobs:
1919
- name: Install dependencies
2020
run: |
2121
python -m pip install --upgrade pip
22-
pip install -q -r requirements-dev.txt
22+
pip install -q -r app/requirements-dev.txt
2323
- name: Check with Black formatter
24-
run: black --check fingerweb finger services
24+
run: black --check app

.github/workflows/test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ jobs:
2121
- name: Install dependencies
2222
run: |
2323
python -m pip install --upgrade pip
24-
pip install -q -r requirements-dev.txt
24+
pip install -q -r app/requirements-dev.txt
2525
- name: Test with pytest
2626
env:
2727
SECRET_KEY: t
2828
ALLOWED_HOSTS: localhost
2929
DATABASE_URL: "sqlite://:memory:"
3030
DEBUG: true
3131
run: |
32+
cd app
3233
pytest

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
*~
22
__pycache__
33

4-
/db.sqlite3
4+
/app/db.sqlite3
55
/finger/static/.sass-cache/
6-
/static/
6+
/app/static/
77
/.env
88
/.vscode
99
/import

Dockerfile

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,57 @@
1-
FROM python:3
21

3-
EXPOSE 8080
2+
#
3+
# Launch a build container so we do not need to care about junk in the production image
4+
#
5+
FROM python:3 AS build
46

5-
# Setup environment, ARG are only available during the build.
6-
ENV PYTHONUNBUFFERED 1
7+
# This is needed to start the Django app
78
ARG SECRET_KEY=none
89
ARG ALLOWED_HOSTS=localhost
910
ARG DATABASE_URL=sqlite:///db.sqlite3
1011

12+
# Install sass
13+
RUN apt-get update
14+
RUN apt-get -y install ruby-sass
15+
16+
# Deploy files and install requirements
17+
ADD app/requirements.txt /app/requirements.txt
18+
RUN pip install -r /app/requirements.txt
19+
ADD app /app
20+
RUN touch /app/.env
21+
RUN mkdir /app/logs
22+
WORKDIR /app
23+
24+
# Migrate (needed) and compile the static assets
25+
RUN /app/manage.py migrate
26+
RUN /app/manage.py compilestatic
27+
RUN /app/manage.py collectstatic --noinput
28+
29+
# Clean up junk
30+
RUN find /app -type f -name *.pyc -delete
31+
RUN find /app -type d -name __pycache__ -delete
32+
RUN find /app -type d -name .sass-cache -exec rm -rf {} \; || :
33+
RUN rm db.sqlite3
34+
35+
#
36+
# The production container
37+
#
38+
FROM python:3
39+
EXPOSE 8080
40+
41+
COPY --from=build /app /app
42+
1143
RUN apt-get update \
12-
&& apt-get -y install ruby-sass nginx \
13-
# Install pip2 for supervisor and supervisor-stdout \
14-
&& apt-get install -y python-pip \
15-
&& pip2 install supervisor supervisor-stdout \
16-
# Remove repo metadata to keep layer size down \
44+
&& apt-get -y install nginx ruby-sass \
1745
&& rm -rf /var/lib/apt/lists/*
1846

19-
ADD requirements.txt /app/requirements.txt
2047
RUN pip install -r /app/requirements.txt
21-
COPY manage.py /app/
22-
COPY finger /app/finger/
23-
COPY fingerweb /app/fingerweb/
24-
COPY services /app/services/
2548
WORKDIR /app
2649

2750
RUN adduser --no-create-home --gecos FALSE --disabled-password finger \
28-
# Get rid of warnings \
29-
&& touch /app/.env \
3051
&& sed -i "s/XXX_BUILD_DATE_XXX/`date +'%F %T'`/" /app/fingerweb/settings.py \
31-
# compilestatic requires an database, hence migrate. \
32-
&& /app/manage.py migrate \
33-
# Compile static resources \
34-
&& /app/manage.py compilestatic \
35-
&& /app/manage.py collectstatic --noinput \
36-
# Clean up, make directories and fix permissions \
37-
&& rm /app/*.sqlite3 \
38-
&& rm /app/*.txt \
39-
&& mkdir /app/logs \
4052
&& chown -R finger:finger /app
4153

4254
ADD conf/nginx.conf /etc/nginx/nginx.conf
43-
ADD conf/supervisord.conf /etc/supervisor/
44-
ADD conf/supervisor/ /etc/supervisor/conf.d/
55+
ADD entrypoint.sh /app/entrypoint.sh
4556

46-
CMD ["supervisord", "-nc", "/etc/supervisor/supervisord.conf"]
57+
CMD /app/entrypoint.sh
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)