-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:HermanMartinus/bearlytics
- Loading branch information
Showing
9 changed files
with
173 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.dockerignore | ||
.env | ||
.gitattributes | ||
.gitignore | ||
analytics | ||
docker-compose.yaml | ||
Dockerfile | ||
Makefile | ||
Procfile | ||
README.md | ||
ROADMAP.md | ||
screenshot.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Create and publish Docker images | ||
|
||
on: | ||
push: | ||
branches: ['main'] | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- name: Checkout respository | ||
uses: actions/checkout@v4 | ||
- name: Log in to the Container registry | ||
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Extract metadata for Docker | ||
id: meta | ||
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
# TODO: figure out versioning / releases | ||
# For now, every push to main will generate an image tagged with 'latest' | ||
# and the commit short hash. | ||
tags: | | ||
type=raw,value=latest,enable={{is_default_branch}} | ||
type=sha | ||
- name: Build and push Docker image | ||
id: push | ||
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,3 +112,4 @@ venv.bak/ | |
.mypy_cache/ | ||
.jsbeautifyrc | ||
|
||
analytics/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
FROM python:3-slim | ||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
curl=7.88.1-10+deb12u8 && \ | ||
rm -rf /var/lib/apt/lists/* && \ | ||
groupadd -g 1000 bear && \ | ||
useradd -u 1000 -g 1000 -m -s /bin/bash bear && \ | ||
mkdir -p /app/data && \ | ||
chown -R bear:bear /app | ||
|
||
WORKDIR /app | ||
|
||
COPY --chown=bear:bear . . | ||
|
||
RUN pip install --no-cache-dir -r requirements.txt && \ | ||
chmod +x docker/entrypoint.sh docker/run.sh | ||
|
||
EXPOSE 8000 | ||
HEALTHCHECK --interval=60s --timeout=30s --start-period=15s --retries=3 \ | ||
CMD curl -f http://localhost:8000/script.js || exit 1 | ||
ENTRYPOINT ["/app/docker/entrypoint.sh"] | ||
CMD ["/app/docker/run.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
services: | ||
bearlytics: | ||
image: ghcr.io/HermanMartinus/bearlytics:latest | ||
ports: | ||
- 8000:8000 | ||
volumes: | ||
- ./analytics:/app/data | ||
environment: | ||
CSRF_TRUSTED_ORIGINS: ${CSRF_TRUSTED_ORIGINS:-http://localhost} | ||
DB_PATH: ${DB_PATH:-/app/data/analytics.db} | ||
DEBUG: False | ||
SALT_SECRET: ${SALT_SECRET:?err} | ||
SECRET_KEY: ${SECRET_KEY:?err} | ||
UID: 1000 | ||
GID: 1000 | ||
restart: unless-stopped | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
export USER=bear | ||
UID=${UID:-1000} | ||
GID=${GID:-1000} | ||
groupmod -o -g "$GID" $USER | ||
usermod -o -u "$UID" $USER | ||
chown -R $USER:$USER /app | ||
|
||
exec su $USER -c "$@" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Run migrations first | ||
python manage.py migrate | ||
|
||
# Start gunicorn | ||
exec gunicorn conf.wsgi --log-file - --bind 0.0.0.0:8000 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters