Skip to content

Commit a1dfcd0

Browse files
Add devcontainer for Python environment (#339)
* feat: Add devcontainer for python * refactor: move devcontainer related files --------- Co-authored-by: Adam Hendel <[email protected]>
1 parent e0c8956 commit a1dfcd0

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM python:3.9
2+
3+
# Install necessary system dependencies
4+
RUN apt-get update && apt-get install -y \
5+
git \
6+
&& rm -rf /var/lib/apt/lists/*
7+
8+
# Create a non-root user
9+
ARG USERNAME=vscode
10+
ARG USER_UID=1000
11+
ARG USER_GID=$USER_UID
12+
13+
RUN groupadd --gid $USER_GID $USERNAME \
14+
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
15+
&& apt-get update \
16+
&& apt-get install -y sudo \
17+
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
18+
&& chmod 0440 /etc/sudoers.d/$USERNAME
19+
20+
# Set the default user
21+
USER $USERNAME
22+
23+
# Set the working directory
24+
WORKDIR /workspace
25+
26+
# Install any global packages you need here
27+
RUN pip install --upgrade pip
28+
29+
# Install poetry and add it to the PATH
30+
RUN pip install --user poetry
31+
32+
# We don't need to copy the project files here, as they will be mounted by VS Code

Diff for: .devcontainer/tembo-pgmq-python/devcontainer.json

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "Python 3.9+ Development Container",
3+
"dockerComposeFile": [
4+
"docker-compose.devcontainer.yml"
5+
],
6+
"containerEnv": {
7+
"POSTGRES_PASSWORD": "postgres",
8+
"SQLALCHEMY_HOST": "pgmq-postgres"
9+
},
10+
"service": "tembo-pgmq-python",
11+
"mounts": [
12+
"source=${localWorkspaceFolder}/tembo-pgmq-python,target=/workspace/tembo-pgmq-python,type=bind,consistency=cached"
13+
],
14+
"workspaceFolder": "/workspace/tembo-pgmq-python",
15+
"postCreateCommand": "poetry install --all-extras",
16+
"customizations": {
17+
"vscode": {
18+
"extensions": [
19+
"ms-python.python",
20+
"ms-python.vscode-pylance"
21+
]
22+
},
23+
"settings": {
24+
"terminal.integrated.defaultProfile.linux": "bash",
25+
"terminal.integrated.profiles.linux": {
26+
"bash": {
27+
"path": "bash",
28+
"icon": "terminal-bash"
29+
}
30+
}
31+
}
32+
},
33+
"remoteUser": "vscode"
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: "3"
2+
services:
3+
pgmq-postgres:
4+
image: quay.io/tembo/pg16-pgmq:latest
5+
container_name: pgmq-postgres
6+
ports:
7+
- "5432:5432"
8+
environment:
9+
- POSTGRES_PASSWORD=postgres
10+
command: ["-c", "max_connections=20000"] # for running tests parallel
11+
volumes:
12+
- ./pgmq-extension/sql/pgmq.sql:/docker-entrypoint-initdb.d/db.sql
13+
networks:
14+
- tembo-pgmq-network
15+
tembo-pgmq-python:
16+
build:
17+
context: ../../tembo-pgmq-python
18+
dockerfile: ../.devcontainer/tembo-pgmq-python/devcontainer.Dockerfile
19+
image: tembo-pgmq-python
20+
container_name: tembo-pgmq-python
21+
networks:
22+
- tembo-pgmq-network
23+
command: ["tail", "-f", "/dev/null"]
24+
networks:
25+
tembo-pgmq-network:
26+
driver: bridge

0 commit comments

Comments
 (0)