Skip to content

Commit

Permalink
add github ci, styling, setup sentry and separate settings
Browse files Browse the repository at this point in the history
  • Loading branch information
nicokant committed Apr 5, 2024
1 parent fd0fd6a commit df46808
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 3 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Docker
on:
workflow_dispatch:
push:
pull_request:

env:
REGISTRY: ghcr.io

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- context: .
image: ghcr.io/ninanor/urban_django

permissions:
contents: read
packages: write

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

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ matrix.image }}
tags: |
type=ref,event=branch
type=sha
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ${{ matrix.context }}
target: ${{ matrix.target }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ RUN chmod +x /usr/bin/celery-cmd
# cd /usr/src/geonode-contribs/ldap; pip install --upgrade -e .

RUN yes w | pip install --src /usr/src -r requirements.txt &&\
yes w | pip install -e .
yes w | pip install -e . &&\
yes w | pip uninstall redis

# Cleanup apt update lists
RUN apt-get autoremove --purge &&\
Expand Down
20 changes: 20 additions & 0 deletions src/fixtures/theme.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{
"model": "geonode_themes.geonodethemecustomization",
"pk": 1,
"fields": {
"date": "2022-09-19T08:42:14.140Z",
"name": "Urban",
"description": "",
"is_enabled": true,
"logo": "home/logo.png",
"extra_css": ":root { --gn-main-color: #000000; --gn-main-bg: #ffffff; --gn-main-border-color: #dddddd; --gn-main-variant-color: #000000; --gn-main-variant-bg: #f2f0f0; --gn-main-hover-color: #000000; --gn-main-hover-bg: #eeeeee; --gn-placeholder-color: #aaaaaa; --gn-placeholder-bg: #dddddd; --gn-disabled-color: #aaaaaa; --gn-disabled-bg: #dddddd; --gn-primary: #333333; --gn-info: #275a7f; --gn-success: #58cf80; --gn-warning: #ebbc35; --gn-danger: #bb4940; --gn-primary-contrast: #ffffff; --gn-info-contrast: #ffffff; --gn-success-contrast: #ffffff; --gn-warning-contrast: #ffffff; --gn-danger-contrast: #ffffff; --gn-link-color: #ff7800; --gn-link-hover-color: #c64600; --gn-image-color: #333333; --gn-image-bg: #f2f2f2; --gn-focus-color: rgba(57, 122, 171, 0.4); --gn-footer-color: #000000; --gn-footer-bg: #ffffff; --gn-footer-link-color: #ff7800; --gn-footer-link-hover-color: #c64600; --gn-badge-color: #000000; --gn-badge-bg: #D5D5D5; --gn-loader-color: #000000; --gn-loader-fade-color: rgba(0, 0, 0, 0.2); --gn-loader-primary-contrast-color: #ffffff; --gn-loader-primary-contrast-fade-color: rgba(255, 255, 255, 0.2); --gn-loader-primary-color: #333333; --gn-loader-primary-fade-color: rgba(51, 51, 51, 0.2); --gn-jumbotron-color: #ffffff; --gn-jumbotron-bg: #deddda; --gn-timeline-selected-bg: rgba(51, 51, 51, 0.05); --gn-timeline-histogram-bg: rgba(51, 51, 51, 0.5); --gn-timeline-histogram-color: #1a1a1a; --gn-timeline-range-bg: rgba(0, 0, 0, 0.2); --gn-timeline-playback-range-bg: rgba(128, 218, 158, 0.2); --gn-button-color: #000000; --gn-button-bg: #ffffff; --gn-button-action-border-color: #dddddd; --gn-button-border-color: #ffffff; --gn-button-focus-color: #000000; --gn-button-focus-bg: #e6e6e6; --gn-button-focus-border-color: #e6e6e6; --gn-button-hover-color: #1a1a1a; --gn-button-hover-bg: #e6e6e6; --gn-button-hover-border-color: #e6e6e6; --gn-button-active-color: #1a1a1a; --gn-button-active-bg: #e6e6e6; --gn-button-active-border-color: #e6e6e6; --gn-button-active-hover-color: #1a1a1a; --gn-button-active-hover-bg: #d4d4d4; --gn-button-active-hover-border-color: #d4d4d4; --gn-button-disabled-color: #acacac; --gn-button-disabled-bg: #fcfcfc; --gn-button-disabled-border-color: #fcfcfc; --gn-button-badge-color: #000000; --gn-button-badge-bg: #ffffff; --gn-button-primary-color: #ffffff; --gn-button-primary-bg: #333333; --gn-button-primary-border-color: #333333; --gn-button-primary-focus-color: #ffffff; --gn-button-primary-focus-bg: #1a1a1a; --gn-button-primary-focus-border-color: #000000; --gn-button-primary-hover-color: #ffffff; --gn-button-primary-hover-bg: #1a1a1a; --gn-button-primary-hover-border-color: #141414; --gn-button-primary-active-color: #ffffff; --gn-button-primary-active-bg: #1a1a1a; --gn-button-primary-active-border-color: #141414; --gn-button-primary-active-hover-color: #ffffff; --gn-button-primary-active-hover-bg: #080808; --gn-button-primary-active-hover-border-color: #000000; --gn-button-primary-disabled-color: #ffffff; --gn-button-primary-disabled-bg: #666666; --gn-button-primary-disabled-border-color: #666666; --gn-button-primary-badge-color: #333333; --gn-button-primary-badge-bg: #ffffff; --gn-button-info-color: #ffffff; --gn-button-info-bg: #275a7f; --gn-button-info-border-color: #275a7f; --gn-button-info-focus-color: #ffffff; --gn-button-info-focus-bg: #1b3e58; --gn-button-info-focus-border-color: #09151d; --gn-button-info-hover-color: #ffffff; --gn-button-info-hover-bg: #1b3e58; --gn-button-info-hover-border-color: #193950; --gn-button-info-active-color: #ffffff; --gn-button-info-active-bg: #1b3e58; --gn-button-info-active-border-color: #193950; --gn-button-info-active-hover-color: #ffffff; --gn-button-info-active-hover-bg: #132b3d; --gn-button-info-active-hover-border-color: #09151d; --gn-button-info-disabled-color: #ffffff; --gn-button-info-disabled-bg: #6a8aa2; --gn-button-info-disabled-border-color: #6a8aa2; --gn-button-info-badge-color: #275a7f; --gn-button-info-badge-bg: #ffffff; --gn-button-success-color: #ffffff; --gn-button-success-bg: #58cf80; --gn-button-success-border-color: #58cf80; --gn-button-success-focus-color: #ffffff; --gn-button-success-focus-bg: #36be64; --gn-button-success-focus-border-color: #258245; --gn-button-success-hover-color: #ffffff; --gn-button-success-hover-bg: #36be64; --gn-button-success-hover-border-color: #34b660; --gn-button-success-active-color: #ffffff; --gn-button-success-active-bg: #36be64; --gn-button-success-active-border-color: #34b660; --gn-button-success-active-hover-color: #ffffff; --gn-button-success-active-hover-bg: #2fa255; --gn-button-success-active-hover-border-color: #258245; --gn-button-success-disabled-color: #ffffff; --gn-button-success-disabled-bg: #b8d5c2; --gn-button-success-disabled-border-color: #b8d5c2; --gn-button-success-badge-color: #58cf80; --gn-button-success-badge-bg: #ffffff; --gn-button-warning-color: #ffffff; --gn-button-warning-bg: #ebbc35; --gn-button-warning-border-color: #ebbc35; --gn-button-warning-focus-color: #ffffff; --gn-button-warning-focus-bg: #d8a515; --gn-button-warning-focus-border-color: #92700e; --gn-button-warning-hover-color: #ffffff; --gn-button-warning-hover-bg: #d8a515; --gn-button-warning-hover-border-color: #ce9e14; --gn-button-warning-active-color: #ffffff; --gn-button-warning-active-bg: #d8a515; --gn-button-warning-active-border-color: #ce9e14; --gn-button-warning-active-hover-color: #ffffff; --gn-button-warning-active-hover-bg: #b78d12; --gn-button-warning-active-hover-border-color: #92700e; --gn-button-warning-disabled-color: #ffffff; --gn-button-warning-disabled-bg: #e2d2a4; --gn-button-warning-disabled-border-color: #e2d2a4; --gn-button-warning-badge-color: #ebbc35; --gn-button-warning-badge-bg: #ffffff; --gn-button-danger-color: #ffffff; --gn-button-danger-bg: #bb4940; --gn-button-danger-border-color: #bb4940; --gn-button-danger-focus-color: #ffffff; --gn-button-danger-focus-bg: #953a33; --gn-button-danger-focus-border-color: #5c241f; --gn-button-danger-hover-color: #ffffff; --gn-button-danger-hover-bg: #953a33; --gn-button-danger-hover-border-color: #8d3730; --gn-button-danger-active-color: #ffffff; --gn-button-danger-active-bg: #953a33; --gn-button-danger-active-border-color: #8d3730; --gn-button-danger-active-hover-color: #ffffff; --gn-button-danger-active-hover-bg: #7a302a; --gn-button-danger-active-hover-border-color: #5c241f; --gn-button-danger-disabled-color: #ffffff; --gn-button-danger-disabled-bg: #bfa4a2; --gn-button-danger-disabled-border-color: #bfa4a2; --gn-button-danger-badge-color: #bb4940; --gn-button-danger-badge-bg: #ffffff; --gn-button-tray-color: #1a1a1a; --gn-button-tray-bg: #ffffff; --gn-button-tray-border-color: #383838; --gn-button-tray-focus-color: #1a1a1a; --gn-button-tray-focus-bg: #e6e6e6; --gn-button-tray-focus-border-color: #0d0d0d; --gn-button-tray-hover-color: #1a1a1a; --gn-button-tray-hover-bg: #e6e6e6; --gn-button-tray-hover-border-color: #2e2e2e; --gn-button-tray-active-color: #1a1a1a; --gn-button-tray-active-bg: #e6e6e6; --gn-button-tray-active-border-color: #2e2e2e; --gn-button-tray-active-hover-color: #1a1a1a; --gn-button-tray-active-hover-bg: #d4d4d4; --gn-button-tray-active-hover-border-color: #0d0d0d; --gn-button-tray-disabled-color: #1a1a1a; --gn-button-tray-disabled-bg: #ffffff; --gn-button-tray-disabled-border-color: #ffffff; --gn-button-tray-badge-color: #ffffff; --gn-button-tray-badge-bg: #1a1a1a; }",
"jumbotron_bg": "home/jumbotron.png",
"jumbotron_welcome_hide": false,
"welcome_theme": "JUMBOTRON_BG",
"jumbotron_welcome_title": "URBAN",
"jumbotron_welcome_content": "Experimental Ecosystem Accounting",
"jumbotron_slide_show": []
}
}
]
6 changes: 6 additions & 0 deletions src/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-e git+https://github.com/GeoNode/geonode-mapstore-client.git@master#egg=django_geonode_mapstore_client
-e git+https://github.com/GeoNode/geonode-importer.git@master#egg=geonode-importer
-e git+https://github.com/GeoNode/geonode.git@master#egg=GeoNode

git+https://github.com/adilhussain540/django-media-fixtures@django-4-fixes

sentry-sdk
sentry-sdk[celery]
sentry-sdk[django]
6 changes: 6 additions & 0 deletions src/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ def statics(ctx):
f"python manage.py collectstatic --noinput --settings={_localsettings()}",
pty=True,
)
ctx.run(f"python manage.py collectmedia --noinput --settings={_localsettings()}")
except Exception:
import traceback

Expand Down Expand Up @@ -396,6 +397,11 @@ def fixtures(ctx):
--settings={_localsettings()}",
pty=True,
)
ctx.run(
f"python manage.py loaddata /usr/src/urban/fixtures/theme.json \
--settings={_localsettings()}",
pty=True,
)


@task
Expand Down
34 changes: 34 additions & 0 deletions src/urban/custom_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import os

from urban.settings import *

INSTALLED_APPS += (
'django_media_fixtures',
)


SENTRY_DSN = os.getenv("SENTRY_DSN", None)
if SENTRY_DSN:
import logging
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
from sentry_sdk.integrations.logging import LoggingIntegration
from sentry_sdk.integrations.celery import CeleryIntegration

SENTRY_LOG_LEVEL = int(os.getenv("DJANGO_SENTRY_LOG_LEVEL", logging.INFO))

sentry_logging = LoggingIntegration(
level=SENTRY_LOG_LEVEL, # Capture info and above as breadcrumbs
event_level=logging.ERROR, # Send errors as events
)

integrations = [sentry_logging, DjangoIntegration(), CeleryIntegration()]

sentry_sdk.init(
dsn=SENTRY_DSN,
integrations=integrations,
environment=os.getenv("SENTRY_ENVIRONMENT", "production"),
traces_sample_rate=float(os.getenv("SENTRY_TRACES_SAMPLE_RATE", 1.0)),
)

LOGGING["loggers"]["sentry_sdk"] = {"level": "ERROR", "handlers": ["console"], "propagate": False}
Binary file added src/urban/media_fixtures/home/jumbotron.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/urban/media_fixtures/home/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion src/urban/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,3 @@

# Add your specific LDAP configuration after this comment:
# https://docs.geonode.org/en/master/advanced/contrib/#configuration

3 changes: 2 additions & 1 deletion src/uwsgi.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[uwsgi]
# uwsgi-socket = 0.0.0.0:8000
http-socket = 0.0.0.0:8000
logto = /var/log/geonode.log
# logto = /var/log/geonode.log
log-master = true
# pidfile = /tmp/geonode.pid

chdir = /usr/src/urban/
Expand Down

0 comments on commit df46808

Please sign in to comment.