datatracker/docker
Robert Sparks 997239a2ea
feat: write objects to blob storage (#8557)
* feat: basic blobstore infrastructure for dev

* refactor: (broken) attempt to put minio console behind nginx

* feat: initialize blobstore with boto3

* fix: abandon attempt to proxy minio. Use docker compose instead.

* feat: beginning of blob writes

* feat: storage utilities

* feat: test buckets

* chore: black

* chore: remove unused import

* chore: avoid f string when not needed

* fix: inform all settings files about blobstores

* fix: declare types for some settings

* ci: point to new target base

* ci: adjust test workflow

* fix: give the tests debug environment a blobstore

* fix: "better" name declarations

* ci: use devblobstore container

* chore: identify places to write to blobstorage

* chore: remove unreachable code

* feat: store materials

* feat: store statements

* feat: store status changes

* feat: store liaison attachments

* feat: store agendas provided with Interim session requests

* chore: capture TODOs

* feat: store polls and chatlogs

* chore: remove unneeded TODO

* feat: store drafts on submit and post

* fix: handle storage during doc expiration and resurrection

* fix: mirror an unlink

* chore: add/refine TODOs

* feat: store slide submissions

* fix: structure slide test correctly

* fix: correct sense of existence check

* feat: store some indexes

* feat: BlobShadowFileSystemStorage

* feat: shadow floorplans / host logos to the blob

* chore: remove unused import

* feat: strip path from blob shadow names

* feat: shadow photos / thumbs

* refactor: combine photo and photothumb blob kinds

The photos / thumbs were already dropped in the same
directory, so let's not add a distinction at this point.

* style: whitespace

* refactor: use kwargs consistently

* chore: migrations

* refactor: better deconstruct(); rebuild migrations

* fix: use new class in mack patch

* chore: add TODO

* feat: store group index documents

* chore: identify more TODO

* feat: store reviews

* fix: repair merge

* chore: remove unnecessary TODO

* feat: StoredObject metadata

* fix: deburr some debugging code

* fix: only set the deleted timestamp once

* chore: correct typo

* fix: get_or_create vs get and test

* fix: avoid the questionable is_seekable helper

* chore: capture future design consideration

* chore: blob store cfg for k8s

* chore: black

* chore: copyright

* ci: bucket name prefix option + run Black

Adds/uses DATATRACKER_BLOB_STORE_BUCKET_PREFIX option. Other changes
are just Black styling.

* ci: fix typo in bucket name expression

* chore: parameters in app-configure-blobstore

Allows use with other blob stores.

* ci: remove verify=False option

* fix: don't return value from __init__

* feat: option to log timing of S3Storage calls

* chore: units

* fix: deleted->null when storing a file

* style: Black

* feat: log as JSON; refactor to share code; handle exceptions

* ci: add ietf_log_blob_timing option for k8s

* test: --no-manage-blobstore option for running tests

* test: use blob store settings from env, if set

* test: actually set a couple more storage opts

* feat: offswitch (#8541)

* feat: offswitch

* fix: apply ENABLE_BLOBSTORAGE to BlobShadowFileSystemStorage behavior

* chore: log timing of blob reads

* chore: import Config from botocore.config

* chore(deps): import boto3-stubs / botocore

botocore is implicitly imported, but make it explicit
since we refer to it directly

* chore: drop type annotation that mypy loudly ignores

* refactor: add storage methods via mixin

Shares code between Document and DocHistory without
putting it in the base DocumentInfo class, which
lacks the name field. Also makes mypy happy.

* feat: add timeout / retry limit to boto client

* ci: let k8s config the timeouts via env

* chore: repair merge resolution typo

* chore: tweak settings imports

* chore: simplify k8s/settings_local.py imports

---------

Co-authored-by: Jennifer Richards <jennifer@staff.ietf.org>
2025-02-19 17:41:10 -06:00
..
assets misc: import docker improvements from 7.39.1.dev2 2021-11-10 21:51:55 +00:00
configs feat: write objects to blob storage (#8557) 2025-02-19 17:41:10 -06:00
scripts feat: write objects to blob storage (#8557) 2025-02-19 17:41:10 -06:00
app.Dockerfile feat: write objects to blob storage (#8557) 2025-02-19 17:41:10 -06:00
base.Dockerfile build: Install fonts from xml2rfc-fonts (#6300) 2024-10-01 10:24:21 -05:00
cleanall fix: Ensure called from the docker directory (#7689) 2024-07-15 16:32:28 -05:00
cleandb fix: Ensure called from the docker directory (#7689) 2024-07-15 16:32:28 -05:00
db.Dockerfile ci: Update db.Dockerfile to postgres 16 2024-06-23 19:28:10 -04:00
devblobstore.Dockerfile ci: dev/test blobstore image (#8431) 2025-01-17 12:35:26 -06:00
docker-compose.celery.yml chore: Remove obsolete version attribute (#7931) 2024-09-12 16:28:44 -05:00
docker-compose.extend.yml feat: write objects to blob storage (#8557) 2025-02-19 17:41:10 -06:00
rabbitmq.conf feat: Celery support and asynchronous draft submission API (#4037) 2022-08-22 13:29:31 -05:00
README.md Added a note on updating older clones 2024-07-15 12:16:13 -05:00
run fix: Make sure "./run" is the invocation (#5724) 2023-06-08 15:27:23 -05:00

Datatracker Development in Docker

Getting started

  1. Set up Docker on your preferred platform. On Windows, it is highly recommended to use the WSL 2 (Windows Subsystem for Linux) backend.

See the IETF Tools Windows Dev guide on how to get started when using Windows.

  1. On Linux, you must install Docker Compose manually and not install Docker Desktop. On Mac and Windows install Docker Desktop which already includes Docker Compose.

  2. If you have a copy of the datatracker code checked out already, simply cd to the top-level directory.

    If not, check out a datatracker branch as usual. We'll check out main below, but you can use any branch:

    git clone https://github.com/ietf-tools/datatracker.git
    cd datatracker
    git checkout main
    
  3. Follow the instructions for your preferred editor:

Using Visual Studio Code

This project includes a devcontainer configuration which automates the setup of the development environment with all the required dependencies.

Initial Setup

  1. Launch VS Code
  2. Under the Extensions tab, ensure you have the Dev Containers (ms-vscode-remote.remote-containers) extension installed.
  1. Open the top-level directory of the datatracker code you fetched above.
  2. A prompt inviting you to reopen the project in containers will appear in the bottom-right corner. Click the Reopen in Container button. If you missed the prompt, you can press F1, start typing reopen in container task and launch it.
  3. VS Code will relaunch in the dev environment and create the containers automatically.
  4. You may get several warnings prompting you to reload the window as extensions get installed for the first time. Wait for the initialization script to complete before doing so. (Wait for the message Done! to appear in the terminal panel.)

Subsequent Launch

To return to your dev environment created above, simply open VS Code and select File > Open Recent and select the datatracker folder with the [Dev Container] suffix.

You can also open the datatracker project folder and click the Reopen in container button when prompted. If you missed the prompt, you can press F1, start typing reopen in container task and launch it.

Usage

  • Under the Run and Debug tab, you can run the server with the debugger attached using Run Server (F5). Once the server is ready to accept connections, you'll be prompted to open in a browser. Navigate to http://localhost:8000 in your preferred browser.

    An alternate profile Run Server with Debug Toolbar is also available from the dropdown menu, which displays various tools on top of the webpage. However, note that this configuration has a significant performance impact.

    To add a Breakpoint, simply click to the left of the line gutter you wish to stop at. You can also add Conditional Breakpoints and Logpoint by right-clicking at the same location.

    While running in debug mode (F5), the following toolbar is shown at the top of the editor:

    See this tutorial on how to use the debugging tools for Django in VS Code.

  • An integrated terminal is available with various shell options (zsh, bash, fish, etc.). Use the New Terminal button located at the right side of the Terminal panel. You can have as many as needed running in parallel and you can use split to display multiple at once.

  • The pgAdmin web interface, a PostgreSQL DB browser / management UI, is available at http://localhost:8000/pgadmin/.

  • Under the Task Explorer tab, a list of available preconfigured tasks is displayed. (You may need to expand the tree to src > vscode to see it.) These are common scritps you can run (e.g. run tests, fetch assets, etc.).

  • From the command palette (F1), the command Run Test Task allows you to choose between running all tests or just the javascript tests.

  • The Ports panel, found in the Terminal area, shows the ports currently mapped to your host and if they are currently listening.

Using Other Editors / Generic

  1. From the terminal, in the top-level directory of the datatracker project:

    On Linux / macOS:

    ./docker/run # or whatever path you need
    

    Note that you can pass the -r flag to run to force a rebuild of the containers. This is useful if you switched branches and that the existing containers still contain configurations from the old branch. You should also use this if you don't regularly keep up with main and your containers reflect a much older version of the branch.

    On Windows (using Powershell):

    Copy-Item "docker/docker-compose.extend.yml" -Destination "docker/docker-compose.extend-custom.yml"
    (Get-Content -path docker/docker-compose.extend-custom.yml -Raw) -replace 'CUSTOM_PORT','8000' | Set-Content -Path docker/docker-compose.extend-custom.yml
    docker compose -f docker-compose.yml -f docker/docker-compose.extend-custom.yml up -d
    docker compose exec app /bin/sh /docker-init.sh
    
  2. Wait for the containers to initialize. Upon completion, you will be dropped into a shell from which you can start the datatracker and execute related commands as usual, for example

    ietf/manage.py runserver 8001
    

    to start the datatracker.

    Once the datatracker has started, you should be able to open http://localhost:8000 in a browser and see the landing page.

    Note that unlike the VS Code setup, a debug SMTP server is launched automatically. Any email will be discarded and logged to the shell.

Exit Environment

To exit the dev environment, simply enter command exit in the shell.

The containers will automatically be shut down on Linux / macOS.

On Windows, type the command

docker compose down

to terminate the containers.

Clean and Rebuild DB from latest image

To delete the active DB container, its volume and get the latest image / DB dump, simply run the following command:

On Linux / macOS:

cd docker
./cleandb

On Windows:

docker compose down -v
docker compose pull db
docker compose build --no-cache db

Clean all

To delete all containers for this project, its associated images and purge any remaining dangling images, simply run the following command:

On Linux / macOS:

cd docker
./cleanall

On Windows:

docker compose down -v --rmi all
docker image prune

Updating an older environment

If you already have a clone, such as from a previous codesprint, and are updating that clone, before starting the datatracker from the updated image:

  • rm ietf/settings_local.py # The startup script will put a new one, appropriate to the current release, in place
  • Execute the Clean all sequence above.

Accessing PostgreSQL Port

The port is exposed but not automatically mapped to 5432 to avoid potential conflicts with the host. To get the mapped port, run the command (from the project /docker directory):

docker compose port db 5432

Notes / Troubleshooting

Slow zsh prompt inside Docker

On Windows, the zsh prompt can become incredibly slow because of the git status check displayed as part of the prompt. To remove this delay, run the command:

git config oh-my-zsh.hide-info 1

Windows .ics files incorrectly linked

When checking out the project on Windows, the .ics files are not correctly linked and will cause many tests to fail. To fix this issue, run the Fix Windows Timezone File Linking task in VS Code or run manually the script docker/scripts/app-win32-timezone-fix.sh

The content of the source files will be copied into the target .ics files. Make sure not to add these modified files when committing code!

Missing assets in the data folder

Because including all assets in the image would significantly increase the file size, they are not included by default. You can however fetch them by running the Fetch assets via rsync task in VS Code or run manually the script docker/scripts/app-rsync-extras.sh

Linux file permissions leaking to the host system

If on the host filesystem you have permissions that look like this,

$ ls -la
total 4624
drwxrwxr-x   2  100999  100999    4096 May 25 07:56 bin
drwxrwxr-x   5  100999  100999    4096 May 25 07:56 client
(etc...)

Try uninstalling Docker Desktop and installing Docker Compose manually. The Docker Compose bundled with Docker Desktop is incompatible with our software. See also Rootless Docker: file ownership changes #3343, Docker context desktop-linux has container permission issues #75.