Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
hepplerj committed Jun 17, 2024
2 parents aa55f39 + 1e23157 commit ff98644
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 49 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.env
.git/
.github/
15 changes: 0 additions & 15 deletions .env.j2

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Build and Publish Docker Image"
name: "Build and Publish, Deploy Docker Image"

on:
workflow_dispatch:
Expand All @@ -9,7 +9,7 @@ on:
- "**"

jobs:
workflow:
build-publish:
uses: chnm/.github/.github/workflows/django--build-publish.yml@main
secrets: inherit
with:
Expand All @@ -21,3 +21,11 @@ jobs:

website-devl-fqdn: "dev.winterthur.rrchnm.org"
website-prod-fqdn: "dev.winterthur.rrchnm.org"

deploy:
uses: chnm/.github/.github/workflows/django--deploy.yml@main
needs: [build-publish]
secrets: inherit
with:
website-devl-fqdn: "dev.winterthur.rrchnm.org"
website-prod-fqdn: "dev.winterthur.rrchnm.org"
28 changes: 11 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ ENV PYTHONUNBUFFERED 1
# Set working directory
WORKDIR /app

# Copy project
COPY . /app/

# Install dependencies with Poetry
COPY poetry.lock pyproject.toml /app/
RUN pip3 install poetry

RUN poetry config virtualenvs.create false
Expand All @@ -40,24 +42,16 @@ RUN ln -s /root/.volta/bin/volta-shim /root/.volta/bin/npx
RUN ln -s /root/.volta/bin/volta-shim /root/.volta/bin/pnpm
RUN ln -s /root/.volta/bin/volta-shim /root/.volta/bin/yarn

# Copy project
COPY . /app/

# triggers node installation
RUN node -v && npm -v

RUN npm install

#ENV TAILWIND_CSS_PATH='../../static/css/dist/styles.css'
#RUN poetry run python3 manage.py tailwind install --no-input
#RUN poetry run python3 manage.py tailwind build --no-input
#RUN poetry run python3 manage.py collectstatic --no-input

#CMD poetry run python3 manage.py runserver 0.0.0.0:8000
# generate front end assets
RUN poetry run python manage.py tailwind install
RUN poetry run python manage.py tailwind build
RUN poetry run python manage.py collectstatic --no-input

CMD bash -c " \
poetry run python3 manage.py tailwind install --no-input && \
poetry run python3 manage.py tailwind build --no-input && \
poetry run python3 manage.py collectstatic --no-input && \
poetry run python3 manage.py runserver 0.0.0.0:8000 \
"
# clean up
RUN rm -rf /root/.volta
RUN rm -rf /app/node_modules
RUN rm -rf /app/static/*
8 changes: 4 additions & 4 deletions config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
# ------------------------------------------------------------------------------

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = env("DJANGO_SECRET_KEY")
SECRET_KEY = env("DJANGO_SECRET_KEY", default="django-insecure cin)v(4&89%_$17s0yezo=t+^1b*mq)=+348r-bv(ms#pm2y2#")

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env("DEBUG")

ALLOWED_HOSTS = env.list("DJANGO_ALLOWED_HOSTS")
CSRF_TRUSTED_ORIGINS = env.list("DJANGO_CSRF_TRUSTED_ORIGINS")
ALLOWED_HOSTS = env.list("DJANGO_ALLOWED_HOSTS", default=['localhost'])
CSRF_TRUSTED_ORIGINS = env.list("DJANGO_CSRF_TRUSTED_ORIGINS", default=['http://localhost'])


# Application definition
Expand Down Expand Up @@ -126,7 +126,7 @@
"PORT": env("DB_PORT", default="5432"),
"NAME": env("DB_NAME", default="denig"),
"USER": env("DB_USER", default="denig"),
"PASSWORD": env("DB_PASSWORD"),
"PASSWORD": env("DB_PASS", default="password"),
}
}

Expand Down
24 changes: 18 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,36 @@ services:
build: .
image: "rrchnm/winterthur"
container_name: "winterthur-app"
env_file: .env
ports:
- 8000:8000
volumes:
- dj-data:/app
environment:
- DEBUG=True
- DJANGO_SECRET_KEY=thisisnotasecretkey
- DJANGO_ALLOWED_HOSTS=localhost
- DJANGO_CSRF_TRUSTED_ORIGINS=http://localhost
- DB_HOST=db
- DB_PORT=5432
- DB_NAME=winterthur
- DB_USER=winterthur
- DB_PASSWORD=password
command: >
sh -c "poetry run python3 manage.py migrate &&
poetry run python3 manage.py tailwind install --no-input &&
poetry run python3 manage.py tailwind build --no-input &&
poetry run python3 manage.py collectstatic --no-input &&
poetry run python3 manage.py runserver 0.0.0.0:8000"
depends_on:
db:
condition: service_healthy
db:
image: postgres:12
image: postgres:16
container_name: "winterthur-db"
env_file: .env
volumes:
- pg-data:/var/lib/postgresql/data
environment:
- POSTGRES_DB=winterthur
- POSTGRES_USER=winterthur
- POSTGRES_PASSWORD=password
- POSTGRES_HOST=db
healthcheck:
test: ["CMD-SHELL", "pg_isready -U winterthur"]
interval: 2s
Expand Down
20 changes: 15 additions & 5 deletions docker-compose.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@ services:
image: ghcr.io/{{ template.git.package.image_name }}:{{ template.git.package.tag }}
container_name: {{ template.name }}_app
restart: unless-stopped
env_file: .env
ports:
- "{{ template.env.host_app_port }}:8000"
environment:
- DEBUG={{ template.env.debug_flag }}
- DJANGO_SECRET_KEY={{ template.env.secret_key }}
- DJANGO_ALLOWED_HOSTS={{ template.env.allowed_hosts }}
- DJANGO_CSRF_TRUSTED_ORIGINS={{ template.env.trusted_origins }}
- DB_HOST=db
- DB_PORT={{ template.env.host_db_port }}
- DB_NAME={{ template.env.db_name }}
- DB_USER={{ template.env.db_user }}
- DB_PASSWORD={{ template.env.db_pass }}
command: >
sh -c "poetry run python3 manage.py migrate &&
poetry run python3 manage.py tailwind install --no-input &&
poetry run python3 manage.py tailwind build --no-input &&
poetry run python3 manage.py collectstatic --no-input &&
poetry run python3 manage.py runserver 0.0.0.0:8000"
volumes:
- dj-static:/app/staticfiles
Expand All @@ -25,9 +31,13 @@ services:
image: postgres:12
container_name: {{ template.name }}_db
restart: unless-stopped
env_file: .env
volumes:
- pg-data:/var/lib/postgresql/data/
environment:
- POSTGRES_DB={{ template.env.db_name }}
- POSTGRES_USER={{ template.env.db_user }}
- POSTGRES_PASSWORD={{ template.env.db_pass }}
- POSTGRES_HOST=db
healthcheck:
test: ["CMD-SHELL", "pg_isready -U {{ template.env.db_user }}"]
interval: 5s
Expand Down

0 comments on commit ff98644

Please sign in to comment.