From dfc3bbd0779a206198090fc9b1587b57b9ff9adc Mon Sep 17 00:00:00 2001 From: cbares <38895035+cbares@users.noreply.github.com> Date: Fri, 10 Oct 2025 08:25:04 +0200 Subject: [PATCH 1/6] first try --- .devcontainer/devcontainer.json | 30 ++++++++++++++++++++++++++++++ .github/workflows/main.yml | 4 ++-- Dockerfile | 14 ++++++++++---- docker-compose.yml | 9 +++++++++ 4 files changed, 51 insertions(+), 6 deletions(-) create mode 100644 .devcontainer/devcontainer.json create mode 100644 docker-compose.yml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..7654bf81 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,30 @@ +{ + "name": "PLT", + "privileged": false, + "remoteUser": "poetry", + "service": "plt", + "dockerComposeFile": "../docker-compose.yml", + "workspaceFolder": "/app", + "customizations": { + "jetbrains": { + "settings": { + "Docker:app:DockerSettings.dockerComposePath": "/usr/local/bin/docker-compose", + "Docker:app:DockerSettings.dockerPath": "/usr/bin/docker" + } + }, + "vscode": { + "extensions": [ + "ms-python.python", + "ms-python.vscode-pylance", + "ms-python.debugpy", + "donjayamanne.python-extension-pack", + "eamodio.gitlens", + "ms-azuretools.vscode-docker", + "dbaeumer.vscode-eslint" + ], + "settings": { + "python.defaultInterpreterPath": "/opt/pysetup/.venv/bin/python" + } + } + } +} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d842cf5c..ae26f484 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,7 +29,7 @@ jobs: run: | set -x sudo apt-get update - sudo apt-get install -yy libsfml-dev libboost-test-dev libmicrohttpd-dev libxml2-dev xvfb lcov gcovr + sudo apt-get install -yy libsfml-dev libboost1.74-all-dev libmicrohttpd-dev libxml2-dev xvfb lcov gcovr - name: switch to gcc-12 on linux run: | @@ -43,7 +43,7 @@ jobs: set -x mkdir build cd build - cmake -DBOOST_ROOT=$BOOST_ROOT_1_69_0 -DBoost_ARCHITECTURE=-x64 .. + cmake -DBOOST_ROOT=$BOOST_ROOT_1_74_0 -DBoost_ARCHITECTURE=-x64 .. # Compile project - name: Compile project diff --git a/Dockerfile b/Dockerfile index 2b1be15d..12e31cbb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,12 @@ -FROM debian:stable-slim +FROM debian:stable-slim as plt-base # Install dependencies RUN apt-get update && apt-get install -y \ build-essential \ cmake \ lcov \ - gcovr + gcovr \ + git RUN apt-get update && apt-get install -y \ libsfml-dev \ @@ -15,13 +16,18 @@ RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \ dia +VOLUME /app + # Set the working directory WORKDIR /app -COPY . /app - # Build the project RUN mkdir docker-build && cd docker-build && cmake .. && make client +RUN rm -rf docker-build + +RUN mkdir docker-build && cd docker-build && cmake .. && make client + + # Run the application CMD ["./bin/client"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..1c809b52 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +services: + plt: + container_name: plt + build: + context: . + dockerfile: Dockerfile + target: plt-base + volumes: + - .:/app From 18297754d803cffd1297dae37289f4aaa9b8973d Mon Sep 17 00:00:00 2001 From: MatthieuGomes Date: Thu, 16 Oct 2025 02:03:26 +0200 Subject: [PATCH 2/6] =?UTF-8?q?premi=C3=A8re=20proposition=20pour=20le=20d?= =?UTF-8?q?ev=20container?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .devcontainer/devcontainer.json | 15 +++------------ Dockerfile | 28 ++++++++++++++++++++-------- docker-compose.yml | 16 ++++++++++++++-- entrypoint.sh | 6 ++++++ 4 files changed, 43 insertions(+), 22 deletions(-) create mode 100644 entrypoint.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 7654bf81..0dd6c573 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,7 +1,7 @@ { "name": "PLT", "privileged": false, - "remoteUser": "poetry", + "remoteUser": "developer", "service": "plt", "dockerComposeFile": "../docker-compose.yml", "workspaceFolder": "/app", @@ -14,17 +14,8 @@ }, "vscode": { "extensions": [ - "ms-python.python", - "ms-python.vscode-pylance", - "ms-python.debugpy", - "donjayamanne.python-extension-pack", - "eamodio.gitlens", - "ms-azuretools.vscode-docker", - "dbaeumer.vscode-eslint" - ], - "settings": { - "python.defaultInterpreterPath": "/opt/pysetup/.venv/bin/python" - } + "ms-vscode.cmake-tools" + ] } } } diff --git a/Dockerfile b/Dockerfile index 12e31cbb..86e19bb9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,21 @@ FROM debian:stable-slim as plt-base +# Set the working directory +WORKDIR /app + +COPY ./src . +COPY ./CMakeLists.txt . +COPY ./.gitignore . +COPY ./extern . +COPY ./cmake . +COPY ./CMakeFiles . +COPY ./lib . +COPY ./test . +COPY ./entrypoint.sh . + # Install dependencies + + RUN apt-get update && apt-get install -y \ build-essential \ cmake \ @@ -16,18 +31,15 @@ RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \ dia -VOLUME /app - -# Set the working directory -WORKDIR /app # Build the project -RUN mkdir docker-build && cd docker-build && cmake .. && make client -RUN rm -rf docker-build +RUN mkdir docker-build && cd docker-build && cmake .. && make client && cd .. -RUN mkdir docker-build && cd docker-build && cmake .. && make client +RUN rm -rf docker-build +RUN chmod +x entrypoint.sh # Run the application -CMD ["./bin/client"] +ENTRYPOINT [ "./entrypoint.sh" ] +CMD ["./bin/client", "/bin/sh"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 1c809b52..7ae5506d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,9 +1,21 @@ services: plt: container_name: plt + working_dir: /app build: context: . dockerfile: Dockerfile - target: plt-base volumes: - - .:/app + - ./CMakeLists.txt:/app/CMakeLists.txt + - .gitignore:/app/.gitignore + - ./src:/app/src + - ./extern:/app/extern + - ./cmake:/app/cmake + - ./CMakeFiles:/app/CMakeFiles + - ./lib:/app/lib + - ./test:/app/test + - ./rapport:/app/rapport + tty: true + stdin_open: true + command: /bin/bash + diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 00000000..bf0b3059 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +set -e + +cd /app +exec "$@" \ No newline at end of file From 81b6211c2f1c66015919ead0263fd784a9bb44fd Mon Sep 17 00:00:00 2001 From: MatthieuGomes Date: Thu, 16 Oct 2025 08:44:10 +0200 Subject: [PATCH 3/6] tentative de gestion des ecrans sous wayland --- docker-compose.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 7ae5506d..5e70f634 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,7 +15,12 @@ services: - ./lib:/app/lib - ./test:/app/test - ./rapport:/app/rapport + - /run/user/${UID}/${WAYLAND_DISPLAY}:/run/${WAYLAND_DISPLAY} tty: true + environment: + - XDG_RUNTIME_DIR=/run/user/${UID} + - WAYLAND_DISPLAY=${WAYLAND_DISPLAY} + stdin_open: true command: /bin/bash From 4a6a588578ea99340b4ccecf46f898be1a468658 Mon Sep 17 00:00:00 2001 From: MatthieuGomes Date: Thu, 16 Oct 2025 11:13:21 +0200 Subject: [PATCH 4/6] ajout du support graphic pour wayland --- Dockerfile | 9 ++++++++- docker-compose.yml | 19 ++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 86e19bb9..ea59c847 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,15 @@ FROM debian:stable-slim as plt-base +ARG USERNAME +ARG USER_UID +ARG USER_GID + # Set the working directory WORKDIR /app +RUN groupadd --gid $USER_GID $USERNAME && \ + useradd --uid $USER_UID --gid $USER_GID -m $USERNAME + COPY ./src . COPY ./CMakeLists.txt . COPY ./.gitignore . @@ -42,4 +49,4 @@ RUN chmod +x entrypoint.sh # Run the application ENTRYPOINT [ "./entrypoint.sh" ] -CMD ["./bin/client", "/bin/sh"] \ No newline at end of file +CMD ["tail", "-f", "/dev/null"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 5e70f634..b6f19135 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,13 @@ services: working_dir: /app build: context: . + args: + - USERNAME=plt + - USER_UID= 1000 # $(id -u) + - USER_GID= 1000 # $(id -g) dockerfile: Dockerfile + # user: $(id -u):$(id -g) + user: $USER_UID:$USER_GID volumes: - ./CMakeLists.txt:/app/CMakeLists.txt - .gitignore:/app/.gitignore @@ -15,12 +21,11 @@ services: - ./lib:/app/lib - ./test:/app/test - ./rapport:/app/rapport - - /run/user/${UID}/${WAYLAND_DISPLAY}:/run/${WAYLAND_DISPLAY} + - $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/tmp/$WAYLAND_DISPLAY tty: true environment: - - XDG_RUNTIME_DIR=/run/user/${UID} - - WAYLAND_DISPLAY=${WAYLAND_DISPLAY} - - stdin_open: true - command: /bin/bash - + - XDG_RUNTIME_DIR=/tmp + - WAYLAND_DISPLAY=$WAYLAND_DISPLAY + - GDK_BACKEND=wayland + - QT_QPA_PLATFORM=wayland + stdin_open: true \ No newline at end of file From 46e352e95fbec199eb8166d2df748936b9aed8fc Mon Sep 17 00:00:00 2001 From: MatthieuGomes Date: Thu, 16 Oct 2025 12:38:37 +0200 Subject: [PATCH 5/6] ajout d'un script de setp + support X11 --- .gitignore | 1 + Dockerfile | 5 +++++ docker-compose.yml | 2 ++ setup_docker.sh | 14 ++++++++++++++ 4 files changed, 22 insertions(+) create mode 100755 setup_docker.sh diff --git a/.gitignore b/.gitignore index 9af4afb8..292a8dfb 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ src/**/*.h .idea *.autosave tmp +.env \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index ea59c847..db0103a4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,7 @@ FROM debian:stable-slim as plt-base ARG USERNAME ARG USER_UID ARG USER_GID +ARG DISPLAY # Set the working directory WORKDIR /app @@ -10,6 +11,10 @@ WORKDIR /app RUN groupadd --gid $USER_GID $USERNAME && \ useradd --uid $USER_UID --gid $USER_GID -m $USERNAME +RUN if [ -n "$DISPLAY" ]; then \ + export DISPLAY=$DISPLAY; \ + fi + COPY ./src . COPY ./CMakeLists.txt . COPY ./.gitignore . diff --git a/docker-compose.yml b/docker-compose.yml index b6f19135..bc6bc9e8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,10 +4,12 @@ services: working_dir: /app build: context: . + ipc: host args: - USERNAME=plt - USER_UID= 1000 # $(id -u) - USER_GID= 1000 # $(id -g) + - DISPLAY= ${DISPLAY:-} dockerfile: Dockerfile # user: $(id -u):$(id -g) user: $USER_UID:$USER_GID diff --git a/setup_docker.sh b/setup_docker.sh new file mode 100755 index 00000000..462ccf54 --- /dev/null +++ b/setup_docker.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +set -e + +echo USERNAME=plt > ./.env +echo USER_UID = $(id -u) >> ./.env +echo USER_GID = $(id -g) >> ./.env + +echo "Checking for display server..." +local display_server=$XDG_SESSION_TYPE +if [ "$display_server" != "wayland" ]; then + xhost +SI:localuser:$(id -un) + echo DISPLAY = $DISPLAY >> ./.env + From eb8511b1cb294040caebb97de6d3c40ea590e06f Mon Sep 17 00:00:00 2001 From: cbares <38895035+cbares@users.noreply.github.com> Date: Fri, 17 Oct 2025 14:20:28 +0200 Subject: [PATCH 6/6] Fix PR for X11 --- .devcontainer/devcontainer.json | 2 +- .gitignore | 3 ++- Dockerfile | 33 +++++++++++++++++---------------- docker-compose.yml | 30 +++++++++++------------------- entrypoint.sh | 6 +++--- setup_docker.sh | 11 +++++------ 6 files changed, 39 insertions(+), 46 deletions(-) mode change 100644 => 100755 entrypoint.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 0dd6c573..cc458223 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,7 +1,7 @@ { "name": "PLT", "privileged": false, - "remoteUser": "developer", + "remoteUser": "plt", "service": "plt", "dockerComposeFile": "../docker-compose.yml", "workspaceFolder": "/app", diff --git a/.gitignore b/.gitignore index 292a8dfb..e7cb5197 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,11 @@ *~ build cmake-build-debug +build-docker bin nbproject src/**/*.h .idea *.autosave tmp -.env \ No newline at end of file +.env diff --git a/Dockerfile b/Dockerfile index db0103a4..d5bbb895 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,10 @@ -FROM debian:stable-slim as plt-base +FROM debian:stable-slim AS plt-base ARG USERNAME ARG USER_UID ARG USER_GID ARG DISPLAY -# Set the working directory -WORKDIR /app RUN groupadd --gid $USER_GID $USERNAME && \ useradd --uid $USER_UID --gid $USER_GID -m $USERNAME @@ -15,15 +13,6 @@ RUN if [ -n "$DISPLAY" ]; then \ export DISPLAY=$DISPLAY; \ fi -COPY ./src . -COPY ./CMakeLists.txt . -COPY ./.gitignore . -COPY ./extern . -COPY ./cmake . -COPY ./CMakeFiles . -COPY ./lib . -COPY ./test . -COPY ./entrypoint.sh . # Install dependencies @@ -41,17 +30,29 @@ RUN apt-get update && apt-get install -y \ libboost-all-dev RUN apt-get update && apt-get install -y \ - dia + dia libcanberra-gtk3-module \ + python3-gi gir1.2-gtk-3.0 + +# Set up user and working directory +RUN chsh -s /bin/bash $USERNAME +USER $USERNAME +WORKDIR /app +COPY --exclude=build --exclude=cmake-build-debug --chown=$USERNAME:$USERNAME . /app +# Set environment variables for GUI support +RUN export GDK_BACKEND=$(if [ ! $WAYLAND_DISPLAY ]; then echo x11; else echo wayland; fi) +RUN export QT_QPA_PLATFORM=$(if [ ! $WAYLAND_DISPLAY ]; then echo xcb; else echo wayland; fi) # Build the project +ENV LC_ALL="C.UTF-8" +ENV LANG="C.UTF-8" RUN mkdir docker-build && cd docker-build && cmake .. && make client && cd .. -RUN rm -rf docker-build +RUN chmod u+x ./entrypoint.sh -RUN chmod +x entrypoint.sh +SHELL ["/bin/bash", "--login", "-c"] # Run the application -ENTRYPOINT [ "./entrypoint.sh" ] +ENTRYPOINT ["./entrypoint.sh"] CMD ["tail", "-f", "/dev/null"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index bc6bc9e8..1d45b13e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,30 +4,22 @@ services: working_dir: /app build: context: . - ipc: host args: - - USERNAME=plt - - USER_UID= 1000 # $(id -u) - - USER_GID= 1000 # $(id -g) - - DISPLAY= ${DISPLAY:-} + USERNAME: ${username:-plt} + USER_UID: ${USER_UID:-1000} # $(id -u) + USER_GID: ${USER_GID:-1000} # $(id -g) + DISPLAY: ${DISPLAY} dockerfile: Dockerfile # user: $(id -u):$(id -g) user: $USER_UID:$USER_GID volumes: - - ./CMakeLists.txt:/app/CMakeLists.txt - - .gitignore:/app/.gitignore - - ./src:/app/src - - ./extern:/app/extern - - ./cmake:/app/cmake - - ./CMakeFiles:/app/CMakeFiles - - ./lib:/app/lib - - ./test:/app/test - - ./rapport:/app/rapport - - $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/tmp/$WAYLAND_DISPLAY + - ./:/app + - /tmp/($WAYLAND_DISPLAY-):/tmp/($WAYLAND_DISPLAY-):rw + - /tmp/.X11-unix:/tmp/.X11-unix:rw + # - /dev/dri:/dev/dri:cached tty: true environment: - - XDG_RUNTIME_DIR=/tmp - - WAYLAND_DISPLAY=$WAYLAND_DISPLAY - - GDK_BACKEND=wayland - - QT_QPA_PLATFORM=wayland + WAYLAND_DISPLAY: ${WAYLAND_DISPLAY:-} + env_file: + - .env stdin_open: true \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh old mode 100644 new mode 100755 index bf0b3059..526b9078 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/bash -set -e +export GDK_BACKEND=$(if [ ! $WAYLAND_DISPLAY ]; then echo x11; else echo wayland; fi) +export QT_QPA_PLATFORM=$(if [ ! $WAYLAND_DISPLAY ]; then echo xcb; else echo wayland; fi) -cd /app exec "$@" \ No newline at end of file diff --git a/setup_docker.sh b/setup_docker.sh index 462ccf54..f8340265 100755 --- a/setup_docker.sh +++ b/setup_docker.sh @@ -3,12 +3,11 @@ set -e echo USERNAME=plt > ./.env -echo USER_UID = $(id -u) >> ./.env -echo USER_GID = $(id -g) >> ./.env +echo USER_UID=$(id -u) >> ./.env +echo USER_GID=$(id -g) >> ./.env echo "Checking for display server..." -local display_server=$XDG_SESSION_TYPE -if [ "$display_server" != "wayland" ]; then +if [ "$XDG_SESSION_TYPE" != "wayland" ]; then xhost +SI:localuser:$(id -un) - echo DISPLAY = $DISPLAY >> ./.env - + echo DISPLAY=$DISPLAY >> ./.env +fi