Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerize Junction #749

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
POSTGRES_USER=postgres
inovizz marked this conversation as resolved.
Show resolved Hide resolved
POSTGRES_PASSWORD=junction
POSTGRES_DB=junction
HOST_NAME=db
PORT=5432
BROKER_URL=redis://redis:6379/0
CELERY_RESULT_BACKEND=redis://redis:6379/0
TESTING=FALSE
SITE_URL=https://in.pycon.org/junction
inovizz marked this conversation as resolved.
Show resolved Hide resolved
SITE_NAME=junction
GOOGLE_ANALYTICS_ID=dummy
FACEBOOK_APP_ID=dummy
EMAIL_HOST_USER=dummy
EMAIL_HOST_PASSWORD=dummy
SECRET_KEY=dummy
TWITTER_CONSUMER_KEY=dummy
TWITTER_CONSUMER_SECRET=dummy
TWITTER_ACCESS_TOKEN_KEY=dummy
TWITTER_ACCESS_TOKEN_SECRET=dummy
USE_ASYNC_FOR_EMAIL=dummy
inovizz marked this conversation as resolved.
Show resolved Hide resolved
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM python:3.10-slim-buster

WORKDIR /code

RUN apt-get update && \
apt-get install -y --no-install-recommends \
gcc \
postgresql-client \
build-essential \
libpq-dev && \
rm -rf /var/lib/apt/lists/*

COPY requirements.txt /code/
RUN pip install --no-cache-dir -r requirements.txt

# Install requirements for running tests
inovizz marked this conversation as resolved.
Show resolved Hide resolved
COPY ./tools/requirements-test.txt /code/
RUN pip install --no-cache-dir -r requirements-test.txt

COPY . /code/
# not getting used at this moment
RUN chmod +x wait-for-it.sh
inovizz marked this conversation as resolved.
Show resolved Hide resolved

ENV DJANGO_SETTINGS_MODULE=settings.dev
ENV PYTHONUNBUFFERED=1

EXPOSE 8888
inovizz marked this conversation as resolved.
Show resolved Hide resolved
23 changes: 23 additions & 0 deletions Dockerfile.celery
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM python:3.10-slim-buster

# Install system dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
gcc \
libc-dev \
libffi-dev \
make \
postgresql-client \
&& rm -rf /var/lib/apt/lists/*

# Install Python dependencies
COPY requirements.txt /app/
RUN pip install --no-cache-dir -r /app/requirements.txt

# Copy the application code
COPY . /app/
WORKDIR /app

# Set environment variables
ENV PYTHONUNBUFFERED 1

inovizz marked this conversation as resolved.
Show resolved Hide resolved
Empty file added docker-compose.prod.yml
Empty file.
11 changes: 11 additions & 0 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: '3.8'

services:
web:
build:
context: .
dockerfile: Dockerfile
command: sh -c pytest --cov=unit --cov=integrations --cov-report=html

volumes:
inovizz marked this conversation as resolved.
Show resolved Hide resolved
postgres_data:
inovizz marked this conversation as resolved.
Show resolved Hide resolved
50 changes: 50 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
version: '3.8'

services:
db:
image: postgres:15-alpine
environment:
inovizz marked this conversation as resolved.
Show resolved Hide resolved
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data/

redis:
image: redis:latest
ports:
- "6379:6379"

celery:
inovizz marked this conversation as resolved.
Show resolved Hide resolved
build:
context: .
dockerfile: Dockerfile.celery
volumes:
- .:/code
depends_on:
- db
- redis
env_file:
- .env
command: sh -c 'celery -A junction worker -l info -E'

web:
build:
context: .
dockerfile: Dockerfile
volumes:
- .:/code
ports:
- "8888:8888"
depends_on:
- db
- redis
- celery
env_file:
- .env
command: sh -c 'python manage.py migrate && python manage.py runsslserver 0.0.0.0:8888'
inovizz marked this conversation as resolved.
Show resolved Hide resolved
ananyo2012 marked this conversation as resolved.
Show resolved Hide resolved

volumes:
postgres_data:
2 changes: 1 addition & 1 deletion junction/conferences/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.db import models
from six import python_2_unicode_compatible
from django.utils.timezone import now
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django_extensions.db.fields import AutoSlugField
from simple_history.models import HistoricalRecords
from slugify import slugify
Expand Down
4 changes: 2 additions & 2 deletions junction/conferences/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

from django.conf.urls import url
from django.urls import re_path

from . import views

urlpatterns = [url(r"^$", views.get_conference, name="get-conference")]
urlpatterns = [re_path(r"^$", views.get_conference, name="get-conference")]
6 changes: 3 additions & 3 deletions junction/profiles/urls.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from django.conf.urls import url
from django.urls import re_path

from . import views

app_name = "junction.profiles"

urlpatterns = [
url(r"^$", views.dashboard, name="dashboard"),
url(r"^edit/$", views.profile, name="profile"),
re_path(r"^$", views.dashboard, name="dashboard"),
re_path(r"^edit/$", views.profile, name="profile"),
]
43 changes: 22 additions & 21 deletions junction/proposals/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,32 @@
from __future__ import absolute_import, unicode_literals

from django.conf.urls import include, url
from django.urls import re_path

from . import comments_views, dashboard, views, votes_views

comment_urls = [
url(
re_path(
r"^(?P<proposal_slug>[\w-]+)/create/$",
comments_views.create_proposal_comment,
name="proposal-comment-create",
),
url(
re_path(
r"^(?P<proposal_slug>[\w-]+)/comments/(?P<proposal_comment_id>\d+)/up-vote/$",
votes_views.proposal_comment_up_vote,
name="proposal-comment-up-vote",
),
url(
re_path(
r"^(?P<proposal_slug>[\w-]+)/comments/(?P<proposal_comment_id>\d+)/down-vote/$",
votes_views.proposal_comment_down_vote,
name="proposal-comment-down-vote",
),
url(
re_path(
r"^(?P<proposal_slug>[\w-]+)/comments/(?P<proposal_comment_id>\d+)/mark_spam/$",
comments_views.mark_comment_as_spam,
name="comment_mark_spam",
),
url(
re_path(
r"^(?P<proposal_slug>[\w-]+)/comments/(?P<proposal_comment_id>\d+)/unmark_spam/$",
comments_views.unmark_comment_as_spam,
name="comment_unmark_spam",
Expand All @@ -35,56 +36,56 @@

urlpatterns = [
# proposal urls
url(r"^$", views.list_proposals, name="proposals-list"),
url(r"^create/$", views.create_proposal, name="proposal-create"),
url(r"^to_review/$", views.proposals_to_review, name="proposals-to-review"),
url(
re_path(r"^$", views.list_proposals, name="proposals-list"),
re_path(r"^create/$", views.create_proposal, name="proposal-create"),
re_path(r"^to_review/$", views.proposals_to_review, name="proposals-to-review"),
re_path(
r"^second_phase_voting/$",
dashboard.second_phase_voting,
name="second-phase-voting",
),
url(r"^(?P<slug>[\w-]+)/$", views.detail_proposal, name="proposal-detail"),
url(
re_path(r"^(?P<slug>[\w-]+)/$", views.detail_proposal, name="proposal-detail"),
re_path(
r"^(?P<slug>[\w-]+)~(?P<hashid>.*)/$",
views.detail_proposal,
name="proposal-detail",
),
url(r"^(?P<slug>[\w-]+)/delete/$", views.delete_proposal, name="proposal-delete"),
url(r"^(?P<slug>[\w-]+)/update/$", views.update_proposal, name="proposal-update"),
url(
re_path(r"^(?P<slug>[\w-]+)/delete/$", views.delete_proposal, name="proposal-delete"),
re_path(r"^(?P<slug>[\w-]+)/update/$", views.update_proposal, name="proposal-update"),
re_path(
r"^(?P<slug>[\w-]+)/upload-content/$",
views.proposal_upload_content,
name="proposal-upload-content",
),
url(
re_path(
r"^(?P<slug>[\w-]+)/change-proposal-review-state/$",
views.review_proposal,
name="proposal-review",
),
# comment urls
url(r"^comment/", include(comment_urls)),
re_path(r"^comment/", include(comment_urls)),
# Voting
url(
re_path(
r"^(?P<proposal_slug>[\w-]+)/down-vote/$",
votes_views.proposal_vote_down,
name="proposal-vote-down",
),
url(
re_path(
r"^(?P<proposal_slug>[\w-]+)/up-vote/$",
votes_views.proposal_vote_up,
name="proposal-vote-up",
),
url(
re_path(
r"^(?P<proposal_slug>[\w-]+)/remove-vote/$",
votes_views.proposal_vote_remove,
name="proposal-vote-remove",
),
url(
re_path(
r"^(?P<proposal_slug>[\w-]+)/vote/$",
votes_views.proposal_reviewer_vote,
name="proposal-reviewer-vote",
),
url(
re_path(
r"^(?P<proposal_slug>[\w-]+)/second-vote/$",
votes_views.proposal_reviewer_secondary_vote,
name="proposal-reviewer-secondary-vote",
Expand Down
4 changes: 2 additions & 2 deletions junction/schedule/urls.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals

from django.conf.urls import url
from django.urls import re_path

from . import views

urlpatterns = [
# schedule urls
url(r"^dummy_schedule/$", views.dummy_schedule, name="dummy_schedule"),
re_path(r"^dummy_schedule/$", views.dummy_schedule, name="dummy_schedule"),
]
4 changes: 2 additions & 2 deletions junction/tickets/urls.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals

from django.conf.urls import url
from django.urls import re_path

from . import views

urlpatterns = [
url(r"^sync_data/$", views.sync_data, name="sync_data"),
re_path(r"^sync_data/$", views.sync_data, name="sync_data"),
]
Loading