Skip to content

Commit

Permalink
Add devcontainer for Python environment (#339)
Browse files Browse the repository at this point in the history
* feat: Add devcontainer for python

* refactor: move devcontainer related files

---------

Co-authored-by: Adam Hendel <[email protected]>
  • Loading branch information
jason810496 and ChuckHend authored Nov 6, 2024
1 parent e0c8956 commit a1dfcd0
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .devcontainer/tembo-pgmq-python/devcontainer.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM python:3.9

# Install necessary system dependencies
RUN apt-get update && apt-get install -y \
git \
&& rm -rf /var/lib/apt/lists/*

# Create a non-root user
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID

RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME

# Set the default user
USER $USERNAME

# Set the working directory
WORKDIR /workspace

# Install any global packages you need here
RUN pip install --upgrade pip

# Install poetry and add it to the PATH
RUN pip install --user poetry

# We don't need to copy the project files here, as they will be mounted by VS Code
34 changes: 34 additions & 0 deletions .devcontainer/tembo-pgmq-python/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "Python 3.9+ Development Container",
"dockerComposeFile": [
"docker-compose.devcontainer.yml"
],
"containerEnv": {
"POSTGRES_PASSWORD": "postgres",
"SQLALCHEMY_HOST": "pgmq-postgres"
},
"service": "tembo-pgmq-python",
"mounts": [
"source=${localWorkspaceFolder}/tembo-pgmq-python,target=/workspace/tembo-pgmq-python,type=bind,consistency=cached"
],
"workspaceFolder": "/workspace/tembo-pgmq-python",
"postCreateCommand": "poetry install --all-extras",
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance"
]
},
"settings": {
"terminal.integrated.defaultProfile.linux": "bash",
"terminal.integrated.profiles.linux": {
"bash": {
"path": "bash",
"icon": "terminal-bash"
}
}
}
},
"remoteUser": "vscode"
}
26 changes: 26 additions & 0 deletions .devcontainer/tembo-pgmq-python/docker-compose.devcontainer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: "3"
services:
pgmq-postgres:
image: quay.io/tembo/pg16-pgmq:latest
container_name: pgmq-postgres
ports:
- "5432:5432"
environment:
- POSTGRES_PASSWORD=postgres
command: ["-c", "max_connections=20000"] # for running tests parallel
volumes:
- ./pgmq-extension/sql/pgmq.sql:/docker-entrypoint-initdb.d/db.sql
networks:
- tembo-pgmq-network
tembo-pgmq-python:
build:
context: ../../tembo-pgmq-python
dockerfile: ../.devcontainer/tembo-pgmq-python/devcontainer.Dockerfile
image: tembo-pgmq-python
container_name: tembo-pgmq-python
networks:
- tembo-pgmq-network
command: ["tail", "-f", "/dev/null"]
networks:
tembo-pgmq-network:
driver: bridge

0 comments on commit a1dfcd0

Please sign in to comment.