add devcontainer configs and docker network orchestration

This commit is contained in:
Jim Moffet
2022-06-13 13:16:32 -07:00
parent e604385e0c
commit 59b72f4853
18 changed files with 388 additions and 82 deletions

View File

@@ -0,0 +1,42 @@
{
"name": "notification-api",
"dockerComposeFile": "../docker-compose.devcontainer.yml",
"service": "dev",
"workspaceFolder": "/workspace",
"shutdownAction": "stopCompose",
"remoteEnv": {
"PATH": "/home/vscode/.local/bin:${containerEnv:PATH}" // give our installed Python modules precedence
},
"settings": {
"[python]": {
"editor.formatOnSave": true
},
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.pythonPath": "/usr/local/bin/python"
},
"features": {
"docker-from-docker": {
"version": "latest",
"moby": true
}
},
"extensions": [
"ms-python.black-formatter",
"donjayamanne.python-extension-pack",
"ms-azuretools.vscode-docker",
"ms-python.vscode-pylance",
"eamodio.gitlens",
"wholroyd.jinja",
"pmbenjamin.vscode-snyk",
"visualstudioexptteam.vscodeintellicode",
"yzhang.markdown-all-in-one",
"ms-ossdata.vscode-postgresql",
"GitHub.copilot",
"ms-vsliveshare.vsliveshare",
"mtxr.sqltools",
"mtxr.sqltools-driver-pg",
],
"postCreateCommand": "notify-dev-entrypoint.sh",
"remoteUser": "vscode"
}

View File

@@ -0,0 +1,40 @@
FROM mcr.microsoft.com/vscode/devcontainers/python:0-3.9
RUN apt-get update \
&& apt-get -y install --no-install-recommends \
apt-utils \
postgresql-client \
2>&1 \
&& apt-get -y install \
curl \
emacs \
exa \
fd-find \
git \
iproute2 \
less \
libsodium-dev \
lsb-release \
man-db \
manpages \
net-tools \
openssh-client \
procps \
sudo \
tldr \
unzip \
vim \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
# Upgrade pip
RUN pip install --upgrade pip
COPY devcontainer-api/scripts/notify-dev-entrypoint.sh /usr/local/bin/
COPY devcontainer-api/scripts/notify-worker-entrypoint.sh /usr/local/bin/
ENV SHELL /bin/zsh
EXPOSE 8000
EXPOSE 6011

View File

@@ -0,0 +1,18 @@
#!/usr/bin/env bash
set -ex
###################################################################
# This script will get executed *once* the Docker container has
# been built. Commands that need to be executed with all available
# tools and the filesystem mount enabled should be located here.
#
# The PostgreSQL Docker image has an extension mechanism that does
# not necessitate to override the entrypoint or main command. One
# simply has to copy a shell script into the
# /docker-entrypoint-initdb.d/ initialization folder.
###################################################################
# Notify database setup.
createdb --user=postgres notification_api
wall "The db container entrypoint setup is complete!"

View File

@@ -0,0 +1,43 @@
#!/bin/bash
set -ex
###################################################################
# This script will get executed *once* the Docker container has
# been built. Commands that need to be executed with all available
# tools and the filesystem mount enabled should be located here.
###################################################################
# Define aliases
echo -e "\n\n# User's Aliases" >> ~/.zshrc
echo -e "alias fd=fdfind" >> ~/.zshrc
echo -e "alias l='ls -al --color'" >> ~/.zshrc
echo -e "alias ls='exa'" >> ~/.zshrc
echo -e "alias l='exa -alh'" >> ~/.zshrc
echo -e "alias ll='exa -alh@ --git'" >> ~/.zshrc
echo -e "alias lt='exa -al -T -L 2'" >> ~/.zshrc
# # Kubectl aliases and command autocomplete
# echo -e "alias k='kubectl'" >> ~/.zshrc
# echo -e "alias k-staging='aws eks --region ca-central-1 update-kubeconfig --name notification-canada-ca-staging-eks-cluster'" >> ~/.zshrc
# echo -e "alias k-prod='aws eks --region ca-central-1 update-kubeconfig --name notification-canada-ca-production-eks-cluster'" >> ~/.zshrc
# echo -e "source <(kubectl completion zsh)" >> ~/.zshrc
# echo -e "complete -F __start_kubectl k" >> ~/.zshrc
cd /workspace
# Warm up git index prior to display status in prompt else it will
# be quite slow on every invocation of starship.
git status
make generate-version-file
pip3 install -r requirements.txt
pip3 install -r requirements_for_test.txt
# Install virtualenv to support running the isolated make freeze-requirements from within the devcontainer
pip3 install virtualenv
# Upgrade schema of the notification_api database
flask db upgrade
# Run flask server
# make run-flask

View File

@@ -0,0 +1,43 @@
#!/bin/bash
set -ex
###################################################################
# This script will get executed *once* the Docker container has
# been built. Commands that need to be executed with all available
# tools and the filesystem mount enabled should be located here.
###################################################################
# Define aliases
echo -e "\n\n# User's Aliases" >> ~/.zshrc
echo -e "alias fd=fdfind" >> ~/.zshrc
echo -e "alias l='ls -al --color'" >> ~/.zshrc
echo -e "alias ls='exa'" >> ~/.zshrc
echo -e "alias l='exa -alh'" >> ~/.zshrc
echo -e "alias ll='exa -alh@ --git'" >> ~/.zshrc
echo -e "alias lt='exa -al -T -L 2'" >> ~/.zshrc
# # Kubectl aliases and command autocomplete
# echo -e "alias k='kubectl'" >> ~/.zshrc
# echo -e "alias k-staging='aws eks --region ca-central-1 update-kubeconfig --name notification-canada-ca-staging-eks-cluster'" >> ~/.zshrc
# echo -e "alias k-prod='aws eks --region ca-central-1 update-kubeconfig --name notification-canada-ca-production-eks-cluster'" >> ~/.zshrc
# echo -e "source <(kubectl completion zsh)" >> ~/.zshrc
# echo -e "complete -F __start_kubectl k" >> ~/.zshrc
cd /workspace
# Warm up git index prior to display status in prompt else it will
# be quite slow on every invocation of starship.
git status
make generate-version-file
pip3 install -r requirements.txt
pip3 install -r requirements_for_test.txt
# Install virtualenv to support running the isolated make freeze-requirements from within the devcontainer
pip3 install virtualenv
# Update commit hash etc...
make generate-version-file
# start listening to the queues
# make run-celery