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
2 changes: 1 addition & 1 deletion .github/workflows/docker-compose-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
pip install -r tests/requirements-test.txt
docker compose -f docker-compose.yml \
-f tests/docker-compose-test.yml up \
--build --exit-code-from backend
--build --exit-code-from backend backend

- name: Setup upterm session
uses: lhotari/action-upterm@v1
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@ safespring_invoicespec.csv
dds_web/development/invoicing/*
dds_variables.env
cython_tools
coverage/*
coverage/*
# Local SeaweedFS (weed mini) data, if volumes are enabled in docker-compose.yml
weedmini-data/
weedmini2-data/
7 changes: 2 additions & 5 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ tasks:
init: >
chmod a+x /workspace/ &&
docker compose build --pull
command: docker compose --profile cli up
command: docker compose up
- name: Open dds cli
openMode: split-right
command: >
Expand All @@ -28,10 +28,7 @@ ports:
# open-browser is blocked by Chrome pop-up blocker
onOpen: ignore
visibility: public
- port: 9000 # minio
onOpen: ignore
visibility: public
- port: 9001 # minio
- port: 9000 # seaweedfs
onOpen: ignore
visibility: public
- port: 3306 # db
Expand Down
61 changes: 30 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
## Table of Contents

- [Development Setup](#development-setup)
- [Profiles](#profiles)
- [Running locally](#running-locally)
- [Debugging inside docker](#python-debugger-inside-docker)
- [Config settings](#config-settings)
- [Database changes](#database-changes)
Expand All @@ -70,55 +70,54 @@ When developing this software, we recommend that you run the web server locally
You can download Docker here: <https://docs.docker.com/get-docker/>

Then, fork this repository and clone to your local system.
In the root folder of the repo, run the server with one of the following profiles (_plain_, _dev_, _full-dev_, _cli_) depending on your needs.

### Profiles
### Running locally

#### Application & Database: Plain
The development environment requires that [dds_cli](https://github.com/ScilifelabDataCentre/dds_cli) is checked out next to this repo, in `../dds_cli` (otherwise adapt the volume path in `docker-compose.yml`). Without it, the `cli` container fails to start.

In the root folder of the repo, start the development environment:

```bash
docker-compose up
docker compose up
```

This command will orchestrate the building and running of two containers: one for the SQL database (`mariadb`) and one for the application.
This builds and starts all containers needed for development:

#### Mailcatcher: `dev`
- `backend`: the web app and API, at `localhost:5000`
- `db`: the MariaDB database
- `redis`: the job queue. To also use it for API rate limiting, uncomment `RATELIMIT_STORAGE_URI` in `docker-compose.yml`
- `weedmini`: SeaweedFS (weed mini) S3 storage, at `localhost:9000`
- `mailcatcher`: catches emails sent by the app; read them at `localhost:1080`
- `cli`: for running the CLI against the local setup (see [below](#cli-development-against-local-environment))
- `node_builder`: recompiles the CSS when SCSS files change

```bash
docker-compose --profile dev up
```
Add `-d` to run in detached mode, and stop the containers with `docker compose down`.

This will give you the above two containers, but also `mailcatcher` that will allow you to read
any sent emails by going to `localhost:1080` in a web browser.

#### Minio S3 Storage & Limiter: `full-dev`
If you are updating from an older setup (for example from before the switch from MinIO to SeaweedFS), remove the old containers before starting:

```bash
docker-compose --profile full-dev up
docker compose down --remove-orphans
```

Will also activate minio for s3 storage (clearly not functional with cli) and redis to enable a persistent limiter for the API.
You also need to uncomment `RATELIMIT_STORAGE_URI` in `docker-compose.yml` to enable redis.

If you prefer, you can run the web servers in 'detached' mode with the `-d` flag, which does not block your terminal.
If using this method, you can stop the web server with the command `docker-compose down`.
Otherwise old containers that are no longer in `docker-compose.yml` can keep running and block ports, and the database keeps data that points to the old storage.

#### CLI development against local environment: `cli`
#### Second S3 storage: `s3-switch`

```bash
docker-compose --profile cli up
docker compose --profile s3-switch up
```

Will start database, backend, minio, and mailcatcher. Will also start an extra container prepared for working with the CLI.
Also starts `weedmini2`, a second SeaweedFS S3 storage at `localhost:9002`. It is only needed for testing a switch between two S3 storages.

Requires that dds_cli is checked out in `../dds_cli` (otherwise adapt the volume path in `docker-compose.yml`).
Stop it with `docker compose --profile s3-switch down`, since a plain `docker compose down` may leave `weedmini2` running.

1. Start docker-compose with the `cli` profile
2. Inject into the `dds_cli` container:
#### CLI development against local environment

```bash
docker exec -it dds_cli /bin/sh
```
The `cli` container runs your local checkout of dds_cli in `../dds_cli`. With the containers running, shell into the `dds_cli` container:

```bash
docker exec -it dds_cli /bin/sh
```

Then you can freely use the dds cli component against the local development setup in the active CLI.

Expand Down Expand Up @@ -184,7 +183,7 @@ For instructions on how to do this, see [the README in the migrations directory]
Tests run on github actions on every pull request and push against master and dev. To run the tests locally, use this command:

```bash
docker-compose -f docker-compose.yml -f tests/docker-compose-test.yml up --build --exit-code-from backend
docker compose -f docker-compose.yml -f tests/docker-compose-test.yml up --build --exit-code-from backend backend
```

This will create a test database in the mariadb container called `DeliverySystemTest` which will be populated before a test and emptied after a test has finished.
Expand All @@ -195,7 +194,7 @@ For example to only run the `test_x` inside the file `tests/test_y.py` you would
To run interactively, use the following command:

```bash
docker-compose -f docker-compose.yml -f tests/docker-compose-test-interactive.yml up --build --exit-code-from backend
docker compose -f docker-compose.yml -f tests/docker-compose-test-interactive.yml up --build --exit-code-from backend backend
```

Then in a new terminal, shell into the container and run pytest:
Expand Down
1 change: 1 addition & 0 deletions SPRINTLOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -705,3 +705,4 @@ _Nothing merged during this sprint_
- Update dependency Mako to v1.4.2 [SECURITY] ([#1880]https://github.com/ScilifelabDataCentre/dds_web/pull/1880)
- Update dependency Authlib to v1.9.1 [SECURITY] ([#1886]https://github.com/ScilifelabDataCentre/dds_web/pull/1886)
- Bump dnspython from 2.6.1 to 2.9.0 ([#1888]https://github.com/ScilifelabDataCentre/dds_web/pull/1888)
- Replace MinIO with SeaweedFS (weed mini) as local S3 storage and make full dev setup the docker compose default ([#1889]https://github.com/ScilifelabDataCentre/dds_web/pull/1889)
6 changes: 3 additions & 3 deletions dds_web/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ class Config(object):
# Expected paths - these are the bind paths *inside* the container
USE_LOCAL_DB = True
LOGS_DIR = "/dds_web/logs"
SAFESPRING_URL = os.environ.get("DDS_SAFESPRING_URL", "http://minio:9000")
SAFESPRING_URL = os.environ.get("DDS_SAFESPRING_URL", "http://weedmini:9000")
DDS_SAFESPRING_PROJECT = os.environ.get("DDS_SAFESPRING_PROJECT", "project-name.example.se")
DDS_SAFESPRING_ACCESS = os.environ.get("DDS_SAFESPRING_ACCESS", "minio")
DDS_SAFESPRING_SECRET = os.environ.get("DDS_SAFESPRING_SECRET", "minioPassword")
DDS_SAFESPRING_ACCESS = os.environ.get("DDS_SAFESPRING_ACCESS", "weedMini")
DDS_SAFESPRING_SECRET = os.environ.get("DDS_SAFESPRING_SECRET", "weedMiniPassword")

# Use short-lived session cookies:
PERMANENT_SESSION_LIFETIME = datetime.timedelta(hours=1)
Expand Down
90 changes: 44 additions & 46 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Use --profile full-dev and uncomment RATELIMIT_STORAGE_URI to use redis
# `docker compose up` starts everything needed for development.
# Add `--profile s3-switch` to also start weedmini2 (only for testing a switch between two S3 storages).
# Uncomment RATELIMIT_STORAGE_URI under backend to use redis for rate limiting.
---
services:
db:
Expand Down Expand Up @@ -96,65 +98,64 @@ services:
source: $DDS_LOG_DIR
target: /dds_web/logs

minio:
container_name: dds_minio
image: pgsty/minio:RELEASE.2026-08-04T00-00-00Z
profiles:
- s3
- full-dev
- cli
command: server /data --console-address ":9001"
# SeaweedFS (weed mini): all SeaweedFS components in one container, serving S3 on port 9000.
# S3 keys come from AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY; data in /data is lost unless a volume is mounted.
# Flags turn off weed mini defaults we don't need:
# -s3.autoCreateBucket=false: uploading to a missing bucket fails instead of creating it
# -master.telemetry=false: no anonymous usage data sent to the SeaweedFS project
# -webdav=false: no WebDAV server (for mounting storage as a network drive)
# -s3.port.iceberg/lance=0: no Iceberg/Lance endpoints (data-catalog tools for analytics/ML)
weedmini:
container_name: dds_weed_mini
image: chrislusf/seaweedfs:4.52
command: >
mini -dir=/data -s3.port=9000
-s3.autoCreateBucket=false
-master.telemetry=false
-webdav=false -s3.port.iceberg=0 -s3.port.lance=0
ports:
- 127.0.0.1:9000:9000
- 127.0.0.1:9001:9001
environment:
MINIO_ROOT_USER: minio # access key
MINIO_ROOT_PASSWORD: minioPassword # secret key
# NOTE: Uncomment if you want to keep your data.
# Mounts a folder into the container to make uploaded data persistent.
# volumes:
# - type: bind
# source: ./minio-data
# target: /data
AWS_ACCESS_KEY_ID: weedMini
AWS_SECRET_ACCESS_KEY: weedMiniPassword
# NOTE: Uncomment if you want to keep your data.
# Mounts a folder into the container to make uploaded data persistent.
# volumes:
# - type: bind
# source: ./weedmini-data
# target: /data

minio2: # Added in order to be able to test the new sto4 move
container_name: dds_minio_2
image: pgsty/minio:RELEASE.2026-08-04T00-00-00Z
profiles:
- s3
- full-dev
- cli
command: server /data --console-address ":9003"
# Second S3 storage, only for testing a switch between storages (--profile s3-switch)
weedmini2:
container_name: dds_weed_mini_2
image: chrislusf/seaweedfs:4.52
profiles: [s3-switch]
command: >
mini -dir=/data -s3.port=9000
-s3.autoCreateBucket=false
-master.telemetry=false
-webdav=false -s3.port.iceberg=0 -s3.port.lance=0
ports:
- 127.0.0.1:9002:9000
- 127.0.0.1:9003:9003
environment:
MINIO_ROOT_USER: minio2 # access key
MINIO_ROOT_PASSWORD: minioPassword2 # secret key
# NOTE: Uncomment if you want to keep your data.
# Mounts a folder into the container to make uploaded data persistent.
# volumes:
# - type: bind
# source: ./minio-data
# target: /data
AWS_ACCESS_KEY_ID: weedMini2
AWS_SECRET_ACCESS_KEY: weedMiniPassword2
# NOTE: Uncomment if you want to keep your data.
# Mounts a folder into the container to make uploaded data persistent.
# volumes:
# - type: bind
# source: ./weedmini2-data
# target: /data

mailcatcher:
container_name: dds_mailcatcher
image: sj26/mailcatcher:latest
profiles:
- dev
- mail
- full-dev
- cli
ports:
- 127.0.0.1:1080:1080

redis:
container_name: dds_redis
image: redis:latest
profiles:
- full-dev
- redis

cli:
container_name: dds_cli
Expand All @@ -163,9 +164,6 @@ services:
dockerfile: Dockerfiles/cli.Dockerfile
context: ./
target: base
profiles:
- cli
- full-dev
environment:
- DDS_CLI_ENV=docker-dev
volumes:
Expand Down
2 changes: 1 addition & 1 deletion migrations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This document explains how to generate new database migration.
Before making any changes to the database models, ensure the containers are running locally.

```bash
docker compose up # See root README for information regarding the different profiles
docker compose up # See the root README for details on the development environment
```

### 2. Modify the Database Models
Expand Down
Loading