Skip to content

Commit d92e060

Browse files
committed
Add logging container
1 parent 6b0195f commit d92e060

6 files changed

Lines changed: 80 additions & 20 deletions

File tree

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Docker Build linux/amd64
1+
name: Docker Build Logs
22

33
on:
44
push:
@@ -24,22 +24,26 @@ jobs:
2424
username: ${{ github.actor }}
2525
password: ${{ secrets.GITHUB_TOKEN }}
2626

27+
- name: Set up QEMU
28+
uses: docker/setup-qemu-action@v3
29+
2730
- name: Set up Docker Buildx
2831
uses: docker/setup-buildx-action@v3
2932

3033
- name: Extract Docker metadata
3134
id: meta
3235
uses: docker/metadata-action@v5
3336
with:
34-
images: ghcr.io/${{ github.repository }}
37+
images: ghcr.io/${{ github.repository }}-logs
3538
tags: |
36-
type=raw,value=amd64-latest
37-
type=raw,value=amd64-${{ github.sha }}
39+
type=raw,value=latest
40+
type=raw,value=${{ github.sha }}
3841
3942
- name: Build and push Docker image
4043
uses: docker/build-push-action@v5
4144
with:
42-
context: .
45+
file: ./Dockerfile.logs
46+
platforms: linux/amd64,linux/arm64
4347
push: true
4448
tags: ${{ steps.meta.outputs.tags }}
4549
labels: ${{ steps.meta.outputs.labels }}
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Docker Build linux/arm64
1+
name: Docker Build Server
22

33
on:
44
push:
@@ -8,7 +8,7 @@ on:
88

99
jobs:
1010
build-and-push:
11-
runs-on: ubuntu-24.04-arm
11+
runs-on: ubuntu-latest
1212
permissions:
1313
contents: read
1414
packages: write # Required for pushing to GHCR
@@ -24,22 +24,26 @@ jobs:
2424
username: ${{ github.actor }}
2525
password: ${{ secrets.GITHUB_TOKEN }}
2626

27+
- name: Set up QEMU
28+
uses: docker/setup-qemu-action@v3
29+
2730
- name: Set up Docker Buildx
2831
uses: docker/setup-buildx-action@v3
2932

3033
- name: Extract Docker metadata
3134
id: meta
3235
uses: docker/metadata-action@v5
3336
with:
34-
images: ghcr.io/${{ github.repository }}
37+
images: ghcr.io/${{ github.repository }}-server
3538
tags: |
36-
type=raw,value=arm64-latest
37-
type=raw,value=arm64-${{ github.sha }}
39+
type=raw,value=latest
40+
type=raw,value=${{ github.sha }}
3841
3942
- name: Build and push Docker image
4043
uses: docker/build-push-action@v5
4144
with:
42-
context: .
45+
file: ./Dockerfile.server
46+
platforms: linux/amd64,linux/arm64
4347
push: true
4448
tags: ${{ steps.meta.outputs.tags }}
4549
labels: ${{ steps.meta.outputs.labels }}

Dockerfile.logs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
FROM python:3.13
2+
3+
# Install uv
4+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
5+
WORKDIR /app
6+
7+
# Install dependencies
8+
# Use host dependencies by default during development to improve build times
9+
RUN --mount=type=cache,target=/root/.cache/uv \
10+
--mount=type=bind,source=uv.lock,target=uv.lock \
11+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
12+
uv sync --locked --no-install-project
13+
14+
# Copy the project into the image
15+
ADD pyproject.toml uv.lock /app/
16+
ADD qretproptools/cli/see_logs /app/qretproptools/cli/see_logs
17+
18+
# Dependencies require the packages to exist
19+
RUN mkdir /app/libqretprop
20+
RUN touch /app/libqretprop/__init__.py /app/qretproptools/__init__.py
21+
22+
RUN ls -l /app
23+
24+
# Sync the project
25+
RUN --mount=type=cache,target=/root/.cache/uv \
26+
uv sync --locked
27+
28+
CMD ["uv", "run", "see_logs", "-e", "-d", "-s"]
File renamed without changes.

compose.yml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
services:
22
server:
33
# Build the image from the Dockerfile in the current directory
4-
build: .
4+
build:
5+
context: .
6+
dockerfile: Dockerfile.server
57
ports:
68
- "8000:8000"
79
depends_on:
810
- redis
9-
environment:
10-
REDIS_HOST: localhost
11+
- logs
1112
network_mode: "host" # Use host networking for SSDP
1213

1314
# Allow manual interaction with the container (cli)
@@ -18,15 +19,32 @@ services:
1819
watch:
1920
# Sync the working directory with the `/app` directory in the container
2021
- action: sync+restart
21-
path: .
22-
target: /app
22+
path: ./libqretprop
23+
target: /app/libqretprop
2324
# Exclude the project virtual environment
2425
ignore:
2526
- .venv/
2627

2728
# Rebuild the image if dependencies change by checking uv.lock
2829
- action: rebuild
2930
path: ./uv.lock
31+
logs:
32+
build:
33+
context: .
34+
dockerfile: Dockerfile.logs
35+
depends_on:
36+
- redis
37+
environment:
38+
REDIS_HOST: redis
39+
tty: true
40+
41+
develop:
42+
watch:
43+
# Sync script changes for development
44+
- action: sync+restart
45+
path: ./qretproptools/cli/see_logs
46+
target: /app/qretproptools/cli/see_logs
47+
3048
redis:
3149
image: "redis:latest"
3250
ports:
@@ -37,7 +55,8 @@ services:
3755

3856
develop:
3957
watch:
40-
# Sync the working directory with the `/app` directory in the container
58+
# Restart on redis.conf changes
59+
# Sync doesn't actually work here because of the volume mount
4160
- action: sync+restart
4261
path: redis.conf
4362
target: /usr/local/etc/redis/redis.conf

qretproptools/cli/see_logs/see_logs.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import redis
55
import redis.exceptions
66

7+
import os
8+
79

810
def main() -> None:
911
parser = argparse.ArgumentParser(description="Tap into QRET logs via Redis.")
@@ -21,16 +23,19 @@ def main() -> None:
2123
print(f"Listening to channels: {', '.join(channels)}")
2224

2325
try:
26+
REDIS_HOST = os.getenv("REDIS_HOST", "localhost")
27+
2428
while True:
2529
r = None
2630
pubsub = None
2731

2832
try:
29-
r = redis.Redis(host="localhost",
33+
34+
r = redis.Redis(host=REDIS_HOST,
3035
port=6379,
3136
db=0,
32-
username="roclient",
33-
password="password",
37+
username="server",
38+
password="propteambestteam",
3439
decode_responses=True,
3540
)
3641
pubsub = r.pubsub()

0 commit comments

Comments
 (0)