Skip to content

Commit

Permalink
Initial commit for Dockerization
Browse files Browse the repository at this point in the history
  • Loading branch information
sanchitcentrica committed Apr 9, 2023
1 parent ca0bf41 commit 519901f
Show file tree
Hide file tree
Showing 16 changed files with 237 additions and 83 deletions.
20 changes: 20 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
POSTGRES_USER=postgres
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
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
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
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

ENV DJANGO_SETTINGS_MODULE=settings.dev
ENV PYTHONUNBUFFERED=1

EXPOSE 8888
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

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:
postgres_data:
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:
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:
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'

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

0 comments on commit 519901f

Please sign in to comment.