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

build(docker): add dockerfiles and compose config #31

Merged
merged 7 commits into from
Oct 18, 2024
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
1 change: 0 additions & 1 deletion api/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
Expand Down
34 changes: 34 additions & 0 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# syntax=docker/dockerfile:1

# NOTE: bullseye instead of alpine as h5py not built for musl :(
FROM python:3.12-slim-bullseye

ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONOPTIMIZE=2

ENV POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
POETRY_VIRTUALENVS_CREATE=1

WORKDIR /src/damnit-web/api

RUN --mount=type=cache,target=/root/.cache \
python3 -m pip install poetry

COPY ./pyproject.toml ./poetry.lock ./

RUN --mount=type=cache,target=/root/.cache \
touch README.md && \
poetry install --no-root --no-directory --only main

COPY ./src ./src

RUN --mount=type=cache,target=/root/.cache \
poetry install --only main

COPY ./README.md ./README.md

EXPOSE 8000

CMD ["poetry", "run", "uvicorn", "damnit_api.main:app", "--host", "0.0.0.0", "--port", "8000"]
11 changes: 11 additions & 0 deletions api/compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: damnit-web-dev

services:
api:
userns_mode: keep-id
ports:
- 8123:8000
volumes:
- /gpfs/exfel/data/scratch/xdana/tmp/damnit-web:/var/tmp
- /gpfs:/gpfs
- /pnfs:/pnfs
11 changes: 11 additions & 0 deletions api/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: damnit-web-local

services:
api:
build: .
env_file:
- .env
ports:
- 8000
volumes:
- ./tmp-damnit-web/:/tmp/damnit-web/
1,939 changes: 1,045 additions & 894 deletions api/poetry.lock

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ h5py = "^3.9.0"
strawberry-graphql = { extras = ["fastapi"], version = "^0.195.2" }
uvicorn = {extras = ["standard"], version = "^0.29.0"}
aiosqlite = "^0.19.0"
pytest = "^7.4.2"
pytest-asyncio = "^0.21.1"
pytest-mock = "^3.11.1"
scipy = "^1.11.4"
authlib = "^1.3.0"
itsdangerous = "^2.1.2"
Expand All @@ -35,6 +32,10 @@ async-lru = "^2.0.4"
ldap3 = "^2.9.1"
requests = "^2.32.3"

[tool.poetry.group.test.dependencies]
pytest = "^7.4.2"
pytest-asyncio = "^0.21.1"
pytest-mock = "^3.11.1"

[tool.poetry.group.dev.dependencies]
strawberry-graphql = { extras = ["debug-server", "fastapi"], version = "^0.195.2" }
Expand Down
2 changes: 1 addition & 1 deletion api/src/damnit_api/metadata/proposals.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from .mymdc import MyMDC


DAMNIT_PROPOSALS_CACHE = "/tmp/damnit_proposals.json"
DAMNIT_PROPOSALS_CACHE = "/tmp/damnit-web/damnit_proposals.json"


@alru_cache(ttl=60)
Expand Down
4 changes: 4 additions & 0 deletions frontend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# .dockerignore
node_modules
.env

20 changes: 20 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# syntax=docker/dockerfile:1

ARG NODE_VERSION=21

FROM node:${NODE_VERSION}

ENV NODE_ENV development

WORKDIR /src/damnit-web/frontend

RUN corepack enable

RUN --mount=type=bind,source=package.json,target=package.json \
--mount=type=bind,source=package-lock.json,target=package-lock.json \
--mount=type=cache,target=/root/.npm \
npm ci

COPY . .

CMD npm start
16 changes: 16 additions & 0 deletions frontend/compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: damnit-web-dev

networks:
proxy:
external: true

services:
frontend:
networks:
- proxy
labels:
- "traefik.enable=true"
- "traefik.docker.network=proxy"
#- "traefik.http.routers.damnit_web_dev.rule=(Host(`damnit-dev.exfldadev01.desy.de`) || Host(`damnit-dev.xfel.eu`)) && PathPrefix(`/feat/deployment`)"
- "traefik.http.routers.damnit_web_dev.rule=(Host(`damnit-dev.exfldadev01.desy.de`) || Host(`damnit-dev.xfel.eu`))"
- "traefik.http.services.damnit_web_dev.loadbalancer.server.port=5173"
9 changes: 9 additions & 0 deletions frontend/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: damnit-web-local

services:
frontend:
build: .
env_file:
- .env
RobertRosca marked this conversation as resolved.
Show resolved Hide resolved
ports:
- 5173