Skip to content

Commit ec8fca5

Browse files
committed
fix(docker): dockerコンテナでpyxelを実行できるようにする
1 parent 121d2e6 commit ec8fca5

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

docker/Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,16 @@ RUN uv venv --python python3.11 .venv && \
4141
uv pip install .[dev]
4242
ENV PATH="/app/.venv/bin:${PATH}"
4343

44-
# 8. Copy Remaining Project Code (Optional)
44+
# 8. Copy Xvfb script
45+
COPY --chown=devuser:devuser docker/run_with_xvfb.sh /usr/local/bin/
46+
47+
# 9. Copy Remaining Project Code (Optional)
4548
# For development, the rest of the code is typically mounted.
4649
# If building an image for deployment, you would uncomment the following:
4750
COPY --chown=devuser:devuser . .
4851

52+
# Set the entrypoint to use Xvfb
53+
ENTRYPOINT ["/usr/local/bin/run_with_xvfb.sh"]
54+
4955
# Default command (can be overridden in docker-compose.yml or docker run)
5056
# CMD ["python", "src/main.py"]

docker/docker-compose.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@ services:
1414
tty: true
1515
stdin_open: true
1616
environment:
17-
- DISPLAY=${DISPLAY}
17+
- DISPLAY=host.docker.internal:0
18+
# 以下はXvfbを使用する場合のみ有効
19+
# - DISPLAY=:99
1820
# - QT_X11_NO_MITSHM=1
1921
# - WAYLAND_DISPLAY=${WAYLAND_DISPLAY}
22+
command: bash
2023
# Named volume for bash history persistence
2124
volumes:
2225
dev_bash_history:

docker/run_with_xvfb.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
# Start Xvfb in the background
3+
Xvfb :99 -screen 0 1024x768x24 -ac &
4+
# Export the display
5+
export DISPLAY=:99
6+
# Execute the command passed to this script
7+
exec "$@"

0 commit comments

Comments
 (0)