diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 5c15c59f53..def7c61d08 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -18,6 +18,7 @@ RUN apt-get update \ exa \ fd-find \ git \ + iputils-ping \ iproute2 \ less \ libsodium-dev \ @@ -51,7 +52,8 @@ RUN apt-get update \ # Upgrade pip RUN pip install --upgrade pip -COPY .devcontainer/scripts/notify-dev-entrypoint.sh /usr/local/bin/ +COPY --chown=vscode:vscode .devcontainer/scripts/notify-dev-entrypoint.sh /usr/local/bin/ +RUN chmod +x /usr/local/bin/notify-dev-entrypoint.sh COPY --chown=vscode:vscode .devcontainer/scripts/installations.sh /usr/local/bin/ RUN chmod -R 765 /usr/local/bin/installations.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 4e41ed3577..2f45fbc1f7 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,31 +1,36 @@ { "name": "notification-admin", - "build": { - "dockerfile": "Dockerfile", - "context": ".." - }, + "dockerComposeFile": "docker-compose.yml", + "service": "notify-admin", + "workspaceFolder": "/workspace", + "shutdownAction": "stopCompose", "remoteEnv": { "PATH": "/home/vscode/.local/bin:${containerEnv:PATH}" // give our installed Python modules precedence }, "containerEnv": { "SHELL": "/bin/zsh" }, - "customizations":{ + "customizations": { "vscode": { "extensions": [ - "njpwerner.autodocstring", + "-ms-python.autopep8", + "charliermarsh.ruff", + "donjayamanne.python-extension-pack", + "eamodio.gitlens", + "fill-labs.dependi", "github.copilot", "GitHub.copilot-labs", - "donjayamanne.python-extension-pack", - "-ms-python.autopep8", + "mechatroner.rainbow-csv", + "ms-azuretools.vscode-docker", + "ms-ossdata.vscode-postgresql", + "ms-python.black-formatter", "ms-python.vscode-pylance", - "eamodio.gitlens", + "njpwerner.autodocstring", "wholroyd.jinja", "visualstudioexptteam.vscodeintellicode", "yzhang.markdown-all-in-one", - "ms-ossdata.vscode-postgresql", "tamasfe.even-better-toml", - "charliermarsh.ruff", + "vsliveshare.vsliveshare" ], "settings": { "ruff.lint.run": "onSave", @@ -38,15 +43,11 @@ } } }, - "features": { "ghcr.io/devcontainers/features/node:1": { "version": "16.20.0" } }, - "forwardPorts": [ - 6012 - ], - "postCreateCommand": "notify-dev-entrypoint.sh", + "postCreateCommand": "/usr/local/bin/notify-dev-entrypoint.sh", "remoteUser": "vscode" } \ No newline at end of file diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 0000000000..10f14be6b8 --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,32 @@ +version: '3' +services: + # Update this to the name of the service you want to work with in your docker-compose.yml file + notify-admin: + build: + context: .. + dockerfile: .devcontainer/Dockerfile + # If you want add a non-root user to your Dockerfile, you can use the "remoteUser" + # property in devcontainer.json to cause VS Code its sub-processes (terminals, tasks, + # debugging) to execute as the user. Uncomment the next line if you want the entire + # container to run as this user instead. Note that, on Linux, you may need to + # ensure the UID and GID of the container user you create matches your local user. + # See https://aka.ms/vscode-remote/containers/non-root for details. + user: vscode + + volumes: + # Update this to wherever you want VS Code to mount the folder of your project + - ..:/workspace:cached + + # Uncomment the next line to use Docker from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker-compose for details. + # - /var/run/docker.sock:/var/run/docker.sock + + # Overrides default command so things don't shut down after the process ends. + command: sleep infinity + expose: + - "6012" + networks: + - notify-network + +networks: + notify-network: + external: true diff --git a/.devcontainer/scripts/installations.sh b/.devcontainer/scripts/installations.sh index 79c569adb2..f009a6b51e 100644 --- a/.devcontainer/scripts/installations.sh +++ b/.devcontainer/scripts/installations.sh @@ -26,12 +26,12 @@ which poetry poetry --version # Initialize poetry autocompletions -mkdir ~/.zfunc +mkdir -p ~/.zfunc touch ~/.zfunc/_poetry poetry completions zsh > ~/.zfunc/_poetry # Install dependencies -cd /workspaces/notification-admin +cd /workspace poetry install # Poe the Poet plugin tab completions diff --git a/.devcontainer/scripts/notify-dev-entrypoint.sh b/.devcontainer/scripts/notify-dev-entrypoint.sh index 94be93cb8a..f28acfba24 100755 --- a/.devcontainer/scripts/notify-dev-entrypoint.sh +++ b/.devcontainer/scripts/notify-dev-entrypoint.sh @@ -10,5 +10,5 @@ set -ex # Tell git the workspace repository is safe, else upcoming commands will fail. git config --global --add safe.directory /workspaces/notification-admin -chown -R vscode:vscode /workspaces/notification-admin -sudo -u vscode -i -- /usr/local/bin/installations.sh +# Install and setup dev environment +installations.sh diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 6b70bb0b31..0000000000 --- a/docker-compose.yml +++ /dev/null @@ -1,19 +0,0 @@ -version: '2' - -services: - web: - restart: on-failure - image: notification-admin - build: - context: ./ - dockerfile: ci/Dockerfile - command: > - bash -c " - make babel && - npm install && - npm run build && - flask run -p 6012 --host=0.0.0.0" - volumes: - - .:/app - ports: - - "6012:6012"