Skip to content
This repository has been archived by the owner on Jul 21, 2024. It is now read-only.

Commit

Permalink
Full docker stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
C4theBomb committed Feb 18, 2024
1 parent a1d739c commit 470c131
Show file tree
Hide file tree
Showing 16 changed files with 236 additions and 219 deletions.
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@
"editor.defaultFormatter": null,
"[dockercompose]": {
"editor.defaultFormatter": "ms-azuretools.vscode-docker"
}
},
"lldb.displayFormat": "auto",
"lldb.showDisassembly": "auto",
"lldb.dereferencePointers": true,
"lldb.consoleMode": "commands"
}
2 changes: 1 addition & 1 deletion CollegiateHouseWars/settings/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .dev import *
from .local import *
17 changes: 1 addition & 16 deletions CollegiateHouseWars/settings/defaults.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
from pathlib import Path
from django.contrib.messages import constants

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent.parent

SECURE_SSL_REDIRECT = False
SESSION_COOKIE_SECURE = False
CSRF_COOKIE_SECURE = False

# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
Expand All @@ -21,7 +18,7 @@
'smart_selects',
'formtools',

'housewars.apps.HousewarsConfig'
'housewars',
]

MIDDLEWARE = [
Expand Down Expand Up @@ -55,9 +52,6 @@

WSGI_APPLICATION = 'CollegiateHouseWars.wsgi.application'

# Password validation
# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
Expand All @@ -73,9 +67,6 @@
},
]

# Internationalization
# https://docs.djangoproject.com/en/4.0/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'
Expand All @@ -84,9 +75,6 @@

USE_TZ = True

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/

STATIC_URL = 'static/'
STATIC_ROOT = BASE_DIR / "staticfiles"

Expand All @@ -108,9 +96,6 @@
},
}

# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'


Expand Down
25 changes: 0 additions & 25 deletions CollegiateHouseWars/settings/dev.py

This file was deleted.

2 changes: 1 addition & 1 deletion CollegiateHouseWars/settings/docker.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .dev import *
from .local import *

DATABASES = {
'default': {
Expand Down
17 changes: 17 additions & 0 deletions CollegiateHouseWars/settings/local.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from .defaults import *

SECRET_KEY = '*9r50c74r58p#*tnfpadsw*cp&$(^sj585w1u@!y9*eowmwl1*'

DEBUG = True

ALLOWED_HOSTS = [
'localhost',
'127.0.0.1',
]

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
7 changes: 1 addition & 6 deletions CollegiateHouseWars/settings/prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

from .defaults import *

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ.get('SECRET_KEY')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
DEBUG = False

ALLOWED_HOSTS = [
'csmb-housewars.c4patino.com'
Expand All @@ -16,9 +14,6 @@
'https://housewars.c4patino.com/'
]

# Database
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
Expand Down
21 changes: 16 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
# syntax=docker/dockerfile:1
FROM python:3.10-slim-bullseye
RUN apt update && apt install build-essential default-libmysqlclient-dev pkg-config -y
FROM python:3.10

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

WORKDIR /app

COPY requirements.txt requirements.txt
RUN python -m pip install -r requirements.txt

RUN pip install --upgrade pip && \
pip install -r requirements.txt && \
pip install gunicorn

COPY . .

RUN python manage.py collectstatic --noinput

EXPOSE 8000/tcp
CMD python manage.py runserver 0.0.0.0:8000

CMD ["gunicorn", "--bind", "0.0.0.0:8000", "CollegiateHouseWars.wsgi:application"]
17 changes: 17 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM python:3.10

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

WORKDIR /app

COPY requirements.txt requirements.txt

RUN pip install --upgrade pip && \
pip install -r requirements.txt

COPY . .

EXPOSE 8000/tcp

CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
18 changes: 0 additions & 18 deletions docker-compose-ec2.yml

This file was deleted.

21 changes: 21 additions & 0 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: '3.8'

services:
csmb-housewars:
restart: unless-stopped
build:
context: .
dockerfile: Dockerfile
image: C4theBomb/csmb-housewars${TAG:-latest}
env_file:
- path: .env
required: true
ports:
- 8000:8000
networks:
- housewars
external_links:
- mysqldb

networks:
housewars: {}
10 changes: 8 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ version: '3.8'
services:
csmb-housewars:
restart: unless-stopped
build: .
image: c4thebomb/csmb-housewars
build:
context: .
dockerfile: Dockerfile.dev
ports:
- 8000:8000
volumes:
- ./:/app

networks:
- housewars
environment:
Expand All @@ -25,6 +27,7 @@ services:
- 3306:3306
volumes:
- housewars-mysql:/var/lib/mysql

networks:
- housewars
environment:
Expand All @@ -34,7 +37,10 @@ services:
test: [ "CMD", "mysqladmin", "ping", "-h", "localhost" ]
timeout: 5s
retries: 10

volumes:
housewars-mysql:


networks:
housewars: {}
55 changes: 28 additions & 27 deletions housewars/templates/housewars/activity_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,39 @@
{% load i18n %}

{% block step-counter %}
<div class="steps-form">
<div class="steps-row setup-panel">
<div class="steps-step">
<button name="wizard_goto_step" class="btn btn-secondary btn-circle" type="submit" value="user">1</button>
<p>Info</p>
</div>
<div class="steps-step">
<button name="wizard_goto_step" class="btn btn-primary btn-circle" type="disabled"
value="activity">2</button>
<p>Activities</p>
</div>
<div class="steps-form">
<div class="steps-row setup-panel">
<div class="steps-step">
<button name="wizard_goto_step" class="btn btn-secondary btn-circle" type="submit" value="user">1</button>
<p>Info</p>
</div>
<div class="steps-step">
<button name="wizard_goto_step" class="btn btn-primary btn-circle" type="disabled"
value="activity">2</button>
<p>Activities</p>
</div>
</div>
</div>
{% endblock %}

{% block content %}
<form method="POST">
{% csrf_token %}
{{ wizard.management_form }}
<form method="POST">
{% csrf_token %}
{{ wizard.management_form }}

<div class="mb-3">
<label for="activity1" class="form-label">Activity 1:</label>
{{ form.activity1 }}
</div>
<div class="mb-3">
<label for="activity2" class="form-label">Activity 2:</label>
{{ form.activity2 }}
</div>
<div class="mb-3">
<label for="activity1" class="form-label">Activity 1:</label>
{{ form.activity1 }}
</div>
<div class="mb-3">
<label for="activity2" class="form-label">Activity 2:</label>
{{ form.activity2 }}
</div>

<div class="form-group d-flex justify-content-center">
<button name="wizard_goto_step" class="btn btn-outline-primary btn-50" type="submit" value="{{ wizard.steps.prev }}">Previous Step</button>
<input id='submit' class="btn btn-outline-primary btn-50" type="submit" value="Submit" />
</div>
</form>
<div class="form-group d-flex justify-content-center">
<button name="wizard_goto_step" class="btn btn-outline-primary btn-50" type="submit"
value="{{ wizard.steps.prev }}">Previous Step</button>
<input id='submit' class="btn btn-outline-primary btn-50" type="submit" value="Submit" />
</div>
</form>
{% endblock %}
Loading

0 comments on commit 470c131

Please sign in to comment.