diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index a1207c4..0ab789e 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -2,9 +2,13 @@ FROM gcc:latest ARG USERNAME +ARG HOME +ARG DOCKER_VOLUME + +ENV USERNAME ${USERNAME} +ENV HOME ${HOME} +ENV DOCKER_VOLUME ${DOCKER_VOLUME} -ENV USERNAME=${USERNAME} -ENV HOME /home/${USERNAME} ENV USER_UID 1000 ENV USER_GID ${USER_UID} @@ -38,20 +42,21 @@ RUN \ \ && usermod -aG sudo ${USERNAME} \ && echo ${USERNAME} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${USERNAME} \ - && chmod 0440 /etc/sudoers.d/${USERNAME} \ - \ - && mkdir -p \ - ${HOME}/.vscode-server/extensions \ - ${HOME}/.vscode-server-insiders/extensions \ - && chown -R ${USERNAME}:${USERNAME} ${HOME} + && chmod 0440 /etc/sudoers.d/${USERNAME} -ENV DOCKER_VOLUME /mnt/docker +ENV DOCKER_VOLUME ${HOME}/volume ENV PROMPT_COMMAND 'history -a' -ENV HISTFILE ${DOCKER_VOLUME}/.bash_history -RUN mkdir ${DOCKER_VOLUME} \ - && touch ${HISTFILE} \ - && chown -R ${USERNAME}:${USERNAME} ${DOCKER_VOLUME} +RUN \ + mkdir -p \ + ${DOCKER_VOLUME} \ + ${DOCKER_VOLUME}/.vscode-server/extensions \ + ${DOCKER_VOLUME}/.vscode-server-insiders/extensions \ + && touch ${DOCKER_VOLUME}/.bash_history \ + && ln -s ${DOCKER_VOLUME}/.bash_history ${HOME}/.bash_history \ + && ln -s ${DOCKER_VOLUME}/.vscode-server ${HOME}/.vscode-server \ + && ln -s ${DOCKER_VOLUME}/.vscode-server-insiders ${HOME}/.vscode-server-insiders \ + && chown -R ${USERNAME}:${USERNAME} ${HOME} WORKDIR ${HOME} USER ${USERNAME} \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index ddc6596..8e02b3b 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,20 +1,18 @@ -// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at: -// https://github.com/microsoft/vscode-dev-containers/tree/v0.128.0/containers/cpp { "name": "gcc:latest", "build": { "dockerfile": "Dockerfile", "args": { - "USERNAME": "${localEnv:DOCKER_USER}" + "USERNAME": "${localEnv:DOCKER_USER}", + "HOME": "/home/${localEnv:DOCKER_USER}", + "DOCKER_VOLUME": "/home/${localEnv:DOCKER_USER}/volume", } }, - // - // NOTICE: - // '--hostname' and '--name' does not work and prevents from running the container - // "runArgs": [ + "--name=vsc-gcc-latest", + "--hostname=gcc", "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" @@ -28,18 +26,11 @@ "ms-vscode.cpptools" ], - // - // NOTICE: - // 'workspaceMount' plus 'workspaceFolder' does not work, workspace is not mounted - // - "containerUser": "${localEnv:DOCKER_USER}", "mounts": [ - "source=vsc-gcc-server-extensions,target=/home/${localEnv:DOCKER_USER}/.vscode-server/extensions,type=volume", - "source=vsc-gcc-insiders-extensions,target=/home/${localEnv:DOCKER_USER}/.vscode-server-insiders/extensions,type=volume", - "source=vsc-gcc-docker-volume,target=/mnt/docker,type=volume" + "source=vsc-gcc-latest-volume,target=/home/${localEnv:DOCKER_USER}/volume,type=volume" ], "postCreateCommand": "" -} \ No newline at end of file +} diff --git a/main.cpp b/main.cpp deleted file mode 100644 index e69de29..0000000