Created
November 25, 2023 00:00
-
-
Save kevinknights29/7cc6cc72630effb41c3969e043bf0b10 to your computer and use it in GitHub Desktop.
Python .devcontainer files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"name": "App", | |
"build":{ | |
"dockerfile": "Dockerfile", | |
"context": "." | |
}, | |
"customizations": { | |
"vscode": { | |
"settings": { | |
"python.defaultInterpreterPath": "/opt/app/.venv/bin/python" | |
}, | |
"extensions": [ | |
"charliermarsh.ruff", | |
"DavidAnson.vscode-markdownlint", | |
"dotenv.dotenv-vscode", | |
"GitHub.copilot", | |
"GitHub.copilot-chat", | |
"KevinRose.vsc-python-indent", | |
"ms-azuretools.vscode-docker", | |
"ms-python.python", | |
"ms-python.vscode-pylance", | |
"ms-vscode-remote.remote-containers", | |
"njpwerner.autodocstring", | |
"ptweir.python-string-sql", | |
"redhat.vscode-yaml", | |
"usernamehw.errorlens", | |
"VisualStudioExptTeam.intellicode-api-usage-examples", | |
"VisualStudioExptTeam.vscodeintellicode" | |
] | |
} | |
}, | |
"runArgs": ["--env-file",".devcontainer/devcontainer.env"] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM python:3.11.4-slim-bullseye | |
ENV LANG=C.UTF-8 \ | |
DEBIAN_FRONTEND=noninteractive | |
# Set working directory | |
WORKDIR /opt/app | |
# Install packages and dependencies | |
RUN apt-get update && \ | |
apt-get install -y --no-install-recommends \ | |
git \ | |
ca-certificates \ | |
build-essential \ | |
zlib1g-dev \ | |
libncurses5-dev \ | |
libgdbm-dev \ | |
libnss3-dev \ | |
libssl-dev \ | |
libreadline-dev \ | |
libffi-dev \ | |
libsqlite3-dev \ | |
libbz2-dev \ | |
unzip \ | |
curl | |
# Copy files | |
COPY requirements.in install_dependencies.sh ./ | |
# Install dependencies | |
RUN bash ./install_dependencies.sh ./requirements.in && \ | |
rm ./install_dependencies.sh ./requirements.in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Check if the path to the requirements file was provided | |
if [ -z "$1" ]; then | |
echo "Please provide the path to the requirements file" | |
exit 1 | |
fi | |
# Installing prerequisites | |
apt-get update && \ | |
apt-get install -y \ | |
build-essential \ | |
python3-launchpadlib \ | |
python3-dev \ | |
python3-pip \ | |
python3-venv \ | |
gcc \ | |
&& apt-get update | |
# Initialize the virtual environment | |
python3 -m venv .venv | |
# Activate the virtual environment | |
source .venv/bin/activate | |
# Set the path of the requirements.txt file | |
REQUIREMENTS_FILE=$1 | |
# Upgrade pip | |
python -m pip install --upgrade pip | |
# Install the Python packages | |
python -m pip install -r $REQUIREMENTS_FILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment