Skip to content

Commit

Permalink
initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
sheppard committed Nov 13, 2023
0 parents commit bfe056d
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build and Publish Image

on: [push]

jobs:
build:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: wq/base

- name: Build and Publish Image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM python:3.11-bookworm

# Install base dependencies
RUN apt-get update && apt-get install -y libgdal32 libsqlite3-mod-spatialite
RUN python -m pip install wq gunicorn whitenoise

# Generate demo project
RUN wq create demo /demo -d localhost -t Demo --with-gis --without-npm
WORKDIR /demo/db
RUN sed -i s/prod/dev/ demo/wsgi.py
RUN sed -i '/SecurityMiddleware/a "whitenoise.middleware.WhiteNoiseMiddleware",' demo/settings/base.py
RUN <<EOF >> demo/settings/dev.py
STORAGES = {
"staticfiles": {
"BACKEND": "whitenoise.storage.CompressedStaticFilesStorage",
},
}
EOF
RUN python manage.py deploy 0.0.0

# Initialize database with test user
RUN python manage.py migrate
RUN python manage.py createsuperuser --noinput --username=testadmin [email protected]
RUN python manage.py shell <<EOF
from django.contrib.auth.models import User
user = User.objects.get(username="testadmin")
user.set_password("testadmin")
user.save()
EOF

# Run server
ENV PYTHONUNBUFFERED 1
EXPOSE 8080
CMD ["gunicorn", "demo.wsgi", "-b", ":8080", "--workers", "2", "--access-logfile", "-"]

0 comments on commit bfe056d

Please sign in to comment.