🚧 This instance is under construction; expect occasional downtime. Runners available in /repos. Questions? Ask in #wikimedia-gitlab on libera.chat, or under GitLab on Phabricator.

Commit 1cd83995 authored by Mhurd's avatar Mhurd
Browse files

initial commit

parents
**/__pycache__
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
README.md
\ No newline at end of file
ddd
metrics.db
\ No newline at end of file
{
"configurations": [
{
"name": "Python: Remote Attach",
"type": "python",
"request": "attach",
"port": 10001,
"host": "localhost",
"pathMappings": [
{
"localRoot": "${workspaceFolder}/",
"remoteRoot": "/app"
}
]
}
]
}
FROM python:3.9.5-slim-buster
# Can increment this to cache-bust commands below if needed
ARG build=0
# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE 1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED 1
# `DDD` uses CONDUIT_TOKEN and CONDUIT_URL
ENV CONDUIT_TOKEN ""
# ENV CONDUIT_URL "http://docker-phabricator-wmf_phabricator_1:80/api/"
ENV CONDUIT_URL "https://phabricator.wikimedia.org/api/"
COPY . /app
WORKDIR /app
RUN cd ddd && \
python3 setup.py install && \
pip3 install poetry && \
poetry install
\ No newline at end of file
startfresh:
docker compose down || true
docker image rm -f ddd-docker_datasette-server || true
docker container rm ddd-docker-datasette-server-1 || true
rm -rf ddd || true
make setupddd
make run
setupddd:
git clone -v -b jinja-dashboards https://gitlab.wikimedia.org/releng/ddd.git
# cd ddd && git checkout remotes/origin/task-metrics www/metadata.yaml
# cd ddd && git checkout 77d72496642a13a3a5d645358c3391bd0c2cc8fb
ln -s ../../metrics.db ddd/www
cd ddd && git submodule update --init
run:
# "compose up" builds and runs ddd-docker-datasette-server
docker compose up
# attachdebugger:
# docker exec -t ddd-docker-datasette-server-1 /bin/bash -c "python3 -c \"from debugger import initialize_debugger_if_needed; initialize_debugger_if_needed()\""
# Set "CONDUIT_TOKEN" in Dockerfile before running "dumpmetrics"!
dumpmetrics:
docker exec -t ddd-docker-datasette-server-1 /bin/bash -c "rm /app/metrics.db || true"
# "cache-columns" only needs to be done once:
docker exec -t ddd-docker-datasette-server-1 /bin/bash -c "cd /app && dddcli metrics cache-columns"
# Can do these when needed for a project w/o having to remove the metrics.db or re-run cache-columns:
# docker exec -t ddd-docker-datasette-server-1 /bin/bash -c "cd /app && dddcli metrics map --mock=maniphest.project.task.transactions.json"
docker exec -t ddd-docker-datasette-server-1 /bin/bash -c "cd /app && dddcli metrics map --project=#design-research"
Dockerized DDD with Datasette. Relevant shortcuts are in the Makefile.
\ No newline at end of file
from os import getenv
def initialize_debugger_if_needed(port: int = 10001):
if getenv("DEBUGGER") == "True":
import multiprocessing
"""
In debug mode Flask uses a first Process (pid 1) to start child processes that handle connections.
If the main process isn't filtered out from the debugging, the debugging port is taken and subsequent
child processes can't use the same port and are attributed a random port which prevents connections.
"""
if multiprocessing.current_process().pid > 1:
import debugpy
debugpy.listen(("0.0.0.0", port))
print("⏳ VS Code debugger can now be attached, press F5 in VS Code ⏳", flush=True)
debugpy.wait_for_client()
print("🎉 VS Code debugger attached, enjoy debugging 🎉", flush=True)
version: '3.4'
services:
datasette-server:
build:
context: .
dockerfile: Dockerfile
# command: tail -f /dev/null
command: bash -c "poetry install && poetry run datasette --metadata www/metadata.yaml -h 0.0.0.0 --reload --setting trace_debug 1 www"
working_dir: /app/ddd
ports:
- 8001:8001
- 10001:10001
volumes:
- .:/app:cached
environment:
DEBUGGER: True
# Only really needed for testing with local dockerized phabricator:
networks:
default:
name: docker-phabricator-wmf_default
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment