Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tie to the custom docker network for the devcontainers #1986

Merged
merged 8 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ RUN apt-get update \
exa \
fd-find \
git \
iputils-ping \
iproute2 \
less \
libsodium-dev \
Expand Down Expand Up @@ -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
Expand Down
33 changes: 17 additions & 16 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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"
}
33 changes: 33 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: '3'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having a docker-compose.yml file gives us more options to customize our VSCode devcontainers.

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: /bin/sh -c "while sleep 1000; do :; done"
command: sleep infinity
expose:
- "6012"
networks:
- notify-network

networks:
notify-network:
external: true
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will attach to the custom network defined in the API project, where it is created.

4 changes: 2 additions & 2 deletions .devcontainer/scripts/installations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .devcontainer/scripts/notify-dev-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering how this script was called previously but could not find it. Does that look ok if I call it from here? cc @jzbahrai @whabanks @andrewleith

19 changes: 0 additions & 19 deletions docker-compose.yml

This file was deleted.

Loading