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

Dev container #79

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
15 changes: 15 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM mcr.microsoft.com/devcontainers/python:0-3.11

ENV PYTHONUNBUFFERED 1

# [Optional] If your requirements rarely change, uncomment this section to add them to the image.
# COPY requirements.txt /tmp/pip-tmp/
# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
# && rm -rf /tmp/pip-tmp

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>



79 changes: 79 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// .devcontainer/devcontainer.json or stored as a .devcontainer.json file (note the dot-prefix) in the root of your project.

// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/postgres
{
"name": "Python 3 & PostgreSQL",
"dockerComposeFile": [
"docker-compose.yml" // development docker-compose
// "../docker-compose.yml" // production docker-compose
],

// The 'service' property is the name of the service for the container that VS Code should
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
"service": "app",

// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
"shutdownAction": "stopCompose",

// The optional 'workspaceFolder' property is the path VS Code should open by default when
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"customizations": {
"vscode": {
"extensions": [
"ms-python.vscode-pylance",
"donjayamanne.python-environment-manager",
"ms-python.python",
"ms-python.pylint",
"ms-python.black-formatter",
"ms-python.isort",
"donjayamanne.python-extension-pack",
"ms-vsliveshare.vsliveshare",
"ms-vscode-remote.remote-wsl",
"ms-vscode-remote.vscode-remote-extensionpack",
"charliermarsh.ruff",
"mtxr.sqltools",
"mtxr.sqltools-driver-pg"
]
}
},

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// This can be used to network with other containers or the host.
"forwardPorts": [8000, 5432],

"portsAttributes": {
"8000": {"label": "Django port", "onAutoForward": "notify"},
"5432": {"label": "PostgreSQL port", "onAutoForward": "silent"}
},

// Uncomment the next line if you want start specific services in your Docker Compose config.
// "runServices": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "pip install --user -r requirements.txt",
// "postCreateCommand": "pip install --user -r indymeet/requirements/requirements-dev.txt"
"postCreateCommand": "sudo apt-get update / sudo apt-get install postgresql-client / pip install -r indymeet/requirements/requirements-dev.txt",
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {
"installDirectlyFromGitHubRelease": true,
"version": "latest"
},
"ghcr.io/devcontainers-contrib/features/gh-release:1": {
"repo": "digitalocean/doctl",
"target": "gh",
"version": "latest"
}
}

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
// "remoteUser": "devcontainer"
}
35 changes: 35 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: '3.8'

services:
app:
build:
context: ..
dockerfile: .devcontainer/Dockerfile

volumes:
- ../..:/workspaces:cached

# Overrides default command so things don't shut down after the process ends.
command: sleep infinity

# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
network_mode: service:db

# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)

db:
image: postgres:latest
restart: unless-stopped
volumes:
- postgres-data:/var/lib/postgresql/data
environment:
POSTGRES_USER: postgres
POSTGRES_DB: postgres
POSTGRES_PASSWORD: postgres

# Add "forwardPorts": ["5432"] to **devcontainer.json** to forward PostgreSQL locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)

volumes:
postgres-data:
64 changes: 64 additions & 0 deletions .devcontainer/test_settings/docker-compose_devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// .devcontainer/devcontainer.json or stored as a .devcontainer.json file (note the dot-prefix) in the root of your project.

// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose
{
"name": "Djangonaut Space",

// Update the 'dockerComposeFile' list if you have more compose files or use different names.
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
// More info: https://containers.dev/guide/dockerfile
"dockerComposeFile": [
"docker-compose.yml", // development docker-compose
"../docker-compose.yml" // production docker-compose
],

// The 'service' property is the name of the service for the container that VS Code should
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
"service": "app",
"shutdownAction": "stopCompose",
// The optional 'workspaceFolder' property is the path VS Code should open by default when
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
// "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}"
"workspaceFolder": "/app/",

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [8000, 5432],

"portsAttributes": {
"8000": {"label": "Django port", "onAutoForward": "notify"},
"5432": {"label": "PostgreSQL port", "onAutoForward": "silent"}
},
// Uncomment the next line if you want start specific services in your Docker Compose config.
// "runServices": [],

// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
// "shutdownAction": "none",

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "pip3 install -r requirements/requirements-dev.txt",

// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"ms-pyton.vscode-pylance",
"ms-python.pylint",
"ms-python.black",
"ms-python.isort",
// "donjayamanne.pythonExtensionPack",
// "donjayamanne.pythonenvironmentmanager",
// "microsoft.docker",
"MS-vsliveshare.vsliveshare",
"ms-vscode-remote.remote-wsl"
]
}
}

// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "devcontainer"
}
75 changes: 75 additions & 0 deletions .devcontainer/test_settings/gui_example_devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"name": "Djangonaut Space",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/python:0-3.11",
"features": {
"ghcr.io/devcontainers/features/aws-cli:1": {
"version": "latest"
},
"ghcr.io/devcontainers/features/oryx:1": {},
"ghcr.io/devcontainers/features/python:1": {
"installTools": true,
"version": "3.11"
},
"ghcr.io/devcontainers-contrib/features/aws-eb-cli:1": {
"version": "latest"
},
"ghcr.io/devcontainers-contrib/features/bandit:2": {
"version": "latest"
},
"ghcr.io/devcontainers-contrib/features/bash-command:1": {
"command": "echo hi!"
},
"ghcr.io/devcontainers-contrib/features/black:2": {
"version": "latest"
},
"ghcr.io/devcontainers-contrib/features/cookiecutter:2": {
"version": "latest"
},
"ghcr.io/devcontainers-contrib/features/flake8:2": {
"version": "latest",
"plugins": "flake8-black"
},
"ghcr.io/devcontainers-contrib/features/isort:2": {
"version": "latest"
},
"ghcr.io/devcontainers-contrib/features/mkdocs:2": {
"version": "latest",
"plugins": "mkdocs-material pymdown-extensions mkdocstrings[crystal,python] mkdocs-monorepo-plugin mkdocs-pdf-export-plugin mkdocs-awesome-pages-plugin"
},
"ghcr.io/devcontainers-contrib/features/poetry:2": {
"version": "latest"
},
"ghcr.io/devcontainers-contrib/features/pre-commit:2": {
"version": "latest"
},
"ghcr.io/eliises/devcontainer-features/bash-profile:1": {
"command": "alias k=kubectl",
"file": "/etc/bash.bashrc"
}
},
"customizations": {
"vscode": {
"extensions": [
"ms-vscode-remote.remote-wsl"
]
}
}

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "pip3 install --user -r requirements.txt",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
1 change: 1 addition & 0 deletions Dockerfile → .devcontainer/test_settings/old_Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Use an official Python runtime based on Debian 10 "buster" as a parent image.
# https://containers.dev/guide/dockerfile#docker-compose-dockerfile
FROM python:3.8.1-slim-buster

# Add user that will be used in the container.
Expand Down
41 changes: 41 additions & 0 deletions .devcontainer/test_settings/old_docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
version: '3'

services:
# Update this to the name of the service you want to work with in your docker-compose.yml file
app:
# Uncomment if you want to override the service's Dockerfile to one in the .devcontainer
# folder. Note that the path of the Dockerfile and context is relative to the *primary*
# docker-compose.yml file (the first in the devcontainer.json "dockerComposeFile"
# array). The sample below assumes your primary file is in the root of your project.
#

# Uncomment the next four lines if you will use a ptrace-based debugger like C++, Go, and Rust.
# cap_add:
# - SYS_PTRACE
# security_opt:
# - seccomp:unconfined

# Official Docker Image https://hub.docker.com/_/python/
image: python:3.11
platform: linux/amd64
environment:
- PYTHONDONTWRITEBYTECODE=1
- PYTHONUNBUFFERED=1
# Overrides default command so things don't shut down after the process ends.
command: python manage.py runserver 0.0.0.0:8000 /bin/sh -c "while sleep 1000; do :; done"
ports:
- 8000:8000
working_dir: /demo-code
volumes:
- ./demo-code:/demo-code:cached
db:
image: postgres:latest
restart: unless-stopped
volumes:
- postgres-data:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: postgres
# volumes:
# postgres-data:
62 changes: 31 additions & 31 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
.idea/
.temp_cache/
db.sqlite3
node_modules/
venv/
build/
__pycache__
*.pyc
*.db
mediafiles/*
media/*
.env
.python-version

staticfiles/*

# dependencies
node_modules

# production
build

# misc
.DS_Store

npm-debug.log
yarn-error.log
yarn.lock
.yarnclean
.vscode
.idea
.idea/
.temp_cache/
db.sqlite3
node_modules/
venv/
build/
__pycache__
*.pyc
*.db
mediafiles/*
media/*
.env
.python-version
staticfiles/*
# dependencies
node_modules
# production
build
# misc
.DS_Store
npm-debug.log
yarn-error.log
yarn.lock
.yarnclean
//.vscode
.idea
.env
Loading