-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #328 from warsztatywww/solutions
Implement solution uploads
- Loading branch information
Showing
30 changed files
with
1,170 additions
and
272 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
node_modules | ||
media | ||
uploads | ||
htmlcov | ||
.mypy_cache | ||
venv | ||
database.sqlite3 | ||
.env | ||
.coverage |
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,39 @@ | ||
FROM node:current-alpine AS build_frontend | ||
WORKDIR /app | ||
|
||
COPY package.json package-lock.json ./ | ||
RUN npm ci | ||
COPY webpack.config.js . | ||
COPY frontend ./frontend | ||
RUN npm run build | ||
|
||
|
||
|
||
FROM python:alpine | ||
WORKDIR /usr/src/app | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
|
||
RUN apk update && apk add postgresql-dev gcc python3-dev musl-dev libffi-dev zlib-dev jpeg-dev | ||
|
||
RUN pip install --upgrade pip | ||
COPY requirements.txt . | ||
RUN pip install -r requirements.txt | ||
RUN pip install gunicorn | ||
|
||
COPY . . | ||
COPY --from=build_frontend /app/static/dist static/dist | ||
|
||
RUN echo "import os" > wwwapp/local_settings.py | ||
RUN echo "SECRET_KEY = os.environ['SECRET_KEY']" >> wwwapp/local_settings.py | ||
RUN echo "ALLOWED_HOSTS = ['*']" >> wwwapp/local_settings.py | ||
RUN echo "DATABASES = {'default': {'ENGINE': 'django.db.backends.postgresql_psycopg2', 'HOST': 'db', 'NAME': 'aplikacjawww', 'USER': 'app', 'PASSWORD': 'app'}}" >> wwwapp/local_settings.py | ||
RUN echo "GOOGLE_ANALYTICS_KEY = None" >> wwwapp/local_settings.py | ||
RUN echo "MEDIA_ROOT = os.environ['MEDIA_ROOT']" >> wwwapp/local_settings.py | ||
RUN echo "SENDFILE_ROOT = os.environ['SENDFILE_ROOT']" >> wwwapp/local_settings.py | ||
RUN echo "USE_X_FORWARDED_HOST = True" >> wwwapp/local_settings.py | ||
RUN echo "SESSION_COOKIE_SECURE = False" >> wwwapp/local_settings.py | ||
RUN echo "CSRF_COOKIE_SECURE = False" >> wwwapp/local_settings.py | ||
|
||
CMD gunicorn wwwapp.wsgi:application --bind 0.0.0.0:8000 | ||
ENTRYPOINT ["./entrypoint.sh"] |
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,48 @@ | ||
version: '3.7' | ||
|
||
services: | ||
django: | ||
build: . | ||
volumes: | ||
- static_volume:/usr/src/static | ||
- media_volume:/usr/src/media | ||
- uploads_volume:/usr/src/uploads | ||
expose: | ||
- 8000 | ||
environment: | ||
- DJANGO_SETTINGS_MODULE=wwwapp.settings_prod | ||
- MEDIA_ROOT=/usr/src/media | ||
- SENDFILE_ROOT=/usr/src/uploads | ||
- SECRET_KEY=test123 | ||
- SOCIAL_AUTH_GOOGLE_OAUTH2_KEY=${SOCIAL_AUTH_GOOGLE_OAUTH2_KEY} | ||
- SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET=${SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET} | ||
- SOCIAL_AUTH_FACEBOOK_KEY=${SOCIAL_AUTH_FACEBOOK_KEY} | ||
- SOCIAL_AUTH_FACEBOOK_SECRET=${SOCIAL_AUTH_FACEBOOK_SECRET} | ||
depends_on: | ||
- db | ||
db: | ||
image: postgres:alpine | ||
volumes: | ||
- postgres_data:/var/lib/postgresql/data/ | ||
environment: | ||
- POSTGRES_DB=aplikacjawww | ||
- POSTGRES_USER=app | ||
- POSTGRES_PASSWORD=app | ||
nginx: | ||
image: nginx:alpine | ||
volumes: | ||
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro | ||
- static_volume:/usr/share/nginx/static | ||
- media_volume:/usr/share/nginx/media | ||
- uploads_volume:/usr/share/nginx/uploads | ||
- ${INTERNETY:-/dev/null}:/usr/share/nginx/internet | ||
ports: | ||
- 8000:8000 | ||
depends_on: | ||
- django | ||
|
||
volumes: | ||
postgres_data: | ||
static_volume: | ||
media_volume: | ||
uploads_volume: |
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,14 @@ | ||
#!/bin/sh | ||
|
||
echo "Collecting static files" | ||
rm -rf /usr/src/static/* | ||
python manage.py collectstatic | ||
|
||
echo "Waiting for postgres..." | ||
while ! nc -z db 5432; do | ||
sleep 0.1 | ||
done | ||
echo "PostgreSQL started" | ||
python manage.py migrate | ||
|
||
exec "$@" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# ResourceYearPermission config example: | ||
# display_name=Internet WWW11, access_url=http://localhost:8080/internet/www11, path=internet/www11, year=2015 | ||
|
||
server { | ||
listen 8000; | ||
listen [::]:8000; | ||
server_name localhost; | ||
|
||
client_max_body_size 32M; | ||
|
||
location / { | ||
proxy_pass http://django:8000; | ||
proxy_redirect off; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Forwarded-Host $host:$server_port; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
|
||
location = /resource_auth/ { | ||
internal; # disallow external access to this endpoint | ||
proxy_pass http://django:8000/resource_auth/; | ||
proxy_redirect off; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Forwarded-Host $host:$server_port; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Original-URI $request_uri; | ||
proxy_set_header Content-Length ""; | ||
proxy_pass_request_body off; | ||
} | ||
} | ||
|
||
location /static { | ||
alias /usr/share/nginx/static/; | ||
} | ||
|
||
location /media { | ||
alias /usr/share/nginx/media/; | ||
} | ||
|
||
location /uploads { | ||
internal; # only allow access through X-Accel-Redirect | ||
alias /usr/share/nginx/uploads/; | ||
} | ||
|
||
location /internet { | ||
alias /usr/share/nginx/internet/; | ||
index index.html index.htm; | ||
autoindex on; | ||
|
||
auth_request /resource_auth/; | ||
error_page 403 =200 /login/; | ||
disable_symlinks on; | ||
|
||
# Earlier internets don't have any specific configuration | ||
|
||
location /internet/www14/ { | ||
# We need to fix the paths because a lot of things were specified relative to / ¯\_(ツ)_/¯ | ||
sub_filter 'href="/' 'href="/internet/www14/'; | ||
sub_filter 'src="/' 'src="/internet/www14/'; | ||
sub_filter 'href=\\"/' 'href=\\"/internet/www14/'; | ||
sub_filter 'src=\\"/' 'src=\\"/internet/www14/'; | ||
sub_filter 'Index of /internet/www14/' 'Index of /'; # required for the scripts to correctly detect the root index page | ||
sub_filter_once off; | ||
sub_filter_types text/plain; # text/html is always included, but we also need to process the cancer1.txt and cancer2.txt files | ||
|
||
# Our magical header/footer config | ||
location ~* ^/internet/www14.*/$ { | ||
add_before_body /internet/www14/cancer1.txt; | ||
add_after_body /internet/www14/cancer2.txt; | ||
} | ||
} | ||
|
||
# I don't have WWW15 files to test but it will be almost identical to WWW14 | ||
} | ||
} |
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
Oops, something went wrong.