Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/ci-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ jobs:
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Set up uv
uses: astral-sh/setup-uv@v5
with:
version: "0.6.5"
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install flake8==4.0.1
pip install bandit==1.7.8
pip install codespell==2.2.4
uv pip install --system flake8==4.0.1 bandit==1.7.8 codespell==2.2.4
- name: Run Flake8
run: |
flake8
Expand Down
22 changes: 16 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# syntax=docker/dockerfile:1.7

FROM python:3.10-alpine AS builder

ENV PYTHONUNBUFFERED=1

COPY --from=ghcr.io/astral-sh/uv:0.6.5 /uv /uvx /bin/

RUN apk add --no-cache \
build-base \
libffi-dev \
Expand All @@ -14,29 +18,35 @@ WORKDIR /install
# Pinned by CI to the commit image-plan.py hashed into this image's content
# key. Defaults to dev so a hand build still works.
ARG COMMON_UTILS_REF=dev
COPY pyproject.toml uv.lock ./
RUN uv sync --frozen --no-dev

RUN --mount=type=secret,id=github_token \
pip install --no-cache-dir --prefix=/install \
uv pip install --no-cache --python /install/.venv/bin/python \
git+https://$(cat /run/secrets/github_token)@github.com/Space-DF/django-common-utils.git@${COMMON_UTILS_REF}

# install python requirements
COPY requirements.txt .
RUN pip install --no-cache-dir --prefix=/install -r requirements.txt

FROM python:3.10-alpine

ENV PYTHONUNBUFFERED=1
ENV DJANGO_SETTINGS_MODULE="device_service.settings"
ENV PATH="/install/.venv/bin:$PATH"

RUN apk add --no-cache \
curl \
libffi \
libstdc++ \
postgresql-client

WORKDIR /app

COPY --from=builder /install /usr/local
COPY --from=builder /install/.venv /install/.venv
COPY . .

RUN adduser --disabled-password --gecos "" appuser \
&& chown -R appuser:appuser /app

RUN ["chmod", "+x", "./docker-entrypoint.sh"]

USER appuser

ENTRYPOINT ["./docker-entrypoint.sh"]
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Prerequisites
- Python 3.10
- uv
- PostgreSQL

## Clone source code
Expand All @@ -13,10 +14,10 @@ git clone -b dev git@github.com:Space-DF/django-common-utils.git

## Setup

- Install requirements
- Install dependencies

```
pip install -r requirements.txt
uv sync
```

- Run RabbitMQ broker
Expand All @@ -31,23 +32,23 @@ git clone -b dev git@github.com:Space-DF/django-common-utils.git

- Migrate
```
python manage.py migrate
uv run python manage.py migrate
```

- Create testing organization
```
python manage.py create_organization
uv run python manage.py create_organization
```

- Create testing space
```
python manage.py create_space
uv run python manage.py create_space
```

## Run source code
- Run server
```
python manage.py runserver 8000
uv run python manage.py runserver 8000
```

- The API documentation will be served on http://<testing organization slug name>.localhost:8000.
Expand All @@ -56,11 +57,11 @@ git clone -b dev git@github.com:Space-DF/django-common-utils.git
When you make the change for the database model
- Make migration file
```
python manage.py makemigrations
uv run python manage.py makemigrations
```
- Migrate
```
python manage.py migrate_schemas
uv run python manage.py migrate_schemas
```

## License
Expand Down
31 changes: 31 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[project]
name = "spacedf-device-service"
version = "0.1.0"
description = "SpaceDF Device Service"
requires-python = ">=3.10,<3.11"
dependencies = [
"Django==5.2.16",
"django-environ==0.11.2",
"gunicorn==22.0.0",
"gevent==24.2.1",
"django-tenants==3.10.2",
"celery==5.4.0",
"cryptography==50.0.0",
"python-dotenv==1.2.2",
"psycopg2-binary==2.9.9",
"djangorestframework==3.17.2",
"djangorestframework-simplejwt==5.5.1",
"django-cors-headers==4.4.0",
"drf-yasg==1.21.7",
"whitenoise==6.7.0",
"django-filter==24.2",
"requests==2.33.0",
"django-redis==5.4.0",
"boto3==1.37.13",
"django-silk==5.3.2",
"pika>=1.3.0",
"setuptools<81.0.0",
]

[tool.uv]
package = false
Loading
Loading