Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker development environment update #4325

Merged
merged 11 commits into from
Jan 10, 2025
39 changes: 39 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM python:3.12.7-bookworm

# Add venv/bin to PATH.
ENV PATH="/opt/app/.venv/bin:/usr/local/bin:$PATH"

# Copy from the cache instead of linking since it's a mounted volume
ENV UV_LINK_MODE=copy

# Set work directory.
WORKDIR /opt/app

# Install node.
COPY --from=node:20.18-slim /usr/local/bin /usr/local/bin
COPY --from=node:20.18-slim /usr/local/lib/node_modules /usr/local/lib/node_modules

# Install uv.
COPY --from=ghcr.io/astral-sh/uv:0.5.13 /uv /uvx /usr/local/bin

# Install node dependencies.
COPY package*.json ./
RUN npm install --quiet

# Install python dependencies.
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync

# Copy the project into the image
COPY ./ ./

# Create directories.
RUN mkdir -p ./hypha/static_compiled && mkdir -p ./hypha/media

# Build front end.
RUN npm run dev:build

# Run entrypoint.sh.
ENTRYPOINT ["/opt/app/docker/entrypoint.sh"]
21 changes: 0 additions & 21 deletions docker/Dockerfile.dev

This file was deleted.

10 changes: 10 additions & 0 deletions docker/Dockerfile.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.cache
.git
.github
.ruff_cache
.venv
.vscode
docs_build
hypha/static_compiled
media
node_modules
41 changes: 41 additions & 0 deletions docker/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: hypha-dev

services:
py:
container_name: hypha-django-dev
build:
context: ..
dockerfile: docker/Dockerfile
environment:
- "DATABASE_URL=postgres://hypha:hypha@db:5432/hypha"
- "DJANGO_SETTINGS_MODULE=hypha.settings.dev"
- "PYTHONDONTWRITEBYTECODE=1"
- "PYTHONUNBUFFERED=1"
- "VIRTUAL_ENV=/opt/app/.venv"
ports:
- 9001:9001
develop:
watch:
- action: sync
path: ..
target: /opt/app
ignore:
- .venv/
- node_modules/
- hypha/static_compiled/
- action: rebuild
path: ./pyproject.toml
frjo marked this conversation as resolved.
Show resolved Hide resolved
depends_on:
- db
db:
container_name: hypha-postgres-dev
image: postgres:14-alpine
volumes:
- postgres_data:/var/lib/postgresql/data/
environment:
- POSTGRES_USER=hypha
- POSTGRES_PASSWORD=hypha
- POSTGRES_DB=hypha

volumes:
postgres_data:
38 changes: 0 additions & 38 deletions docker/docker-compose.yaml

This file was deleted.

16 changes: 0 additions & 16 deletions docker/entrypoint.dev.sh

This file was deleted.

15 changes: 15 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -e

# Run needed python commands.
python manage.py createcachetable
python manage.py migrate --noinput
python manage.py clear_cache --cache=default
python manage.py sync_roles
python manage.py wagtailsiteupdate hypha.test 9001

# Start dev server.
npm run watch &
python manage.py runserver_plus 0.0.0.0:9001

exec "$@"
24 changes: 0 additions & 24 deletions docker/nginx/hypha.conf

This file was deleted.

Loading