Verzia 0.1 - funkčná
This commit is contained in:
31
.devcontainer/Dockerfile
Normal file
31
.devcontainer/Dockerfile
Normal file
@@ -0,0 +1,31 @@
|
||||
# Používame oficiálny Python image, ale env bude podobné ako v base:ubuntu
|
||||
ARG PYTHON_VERSION=3.13
|
||||
FROM python:${PYTHON_VERSION}-slim
|
||||
|
||||
ENV PYTHONUNBUFFERED=1 \
|
||||
PIP_NO_CACHE_DIR=1 \
|
||||
PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
||||
VIRTUAL_ENV=/workspace/.venv \
|
||||
PATH="/workspace/.venv/bin:${PATH}"
|
||||
|
||||
# Základ + Docker repo + docker-ce-cli + compose plugin + git
|
||||
RUN set -eux; \
|
||||
apt-get update && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
||||
ca-certificates curl gnupg && \
|
||||
install -m 0755 -d /etc/apt/keyrings && \
|
||||
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg && \
|
||||
chmod a+r /etc/apt/keyrings/docker.gpg && \
|
||||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
|
||||
https://download.docker.com/linux/debian $(. /etc/os-release && echo $VERSION_CODENAME) stable" \
|
||||
> /etc/apt/sources.list.d/docker.list && \
|
||||
apt-get update && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
||||
build-essential pkg-config \
|
||||
git \
|
||||
docker-ce-cli docker-compose-plugin docker-buildx-plugin \
|
||||
libatomic1 libstdc++6 libgcc-s1 \
|
||||
procps \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /workspace
|
||||
52
.devcontainer/devcontainer.json
Normal file
52
.devcontainer/devcontainer.json
Normal file
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"name": "Python Dev",
|
||||
"build": {
|
||||
"dockerfile": "Dockerfile",
|
||||
"context": ".",
|
||||
"args": {
|
||||
"PYTHON_VERSION": "3.13"
|
||||
}
|
||||
},
|
||||
"containerEnv": {
|
||||
"PIP_INDEX_URL": "https://dv.masara.eu/repository/pypi-group/simple"
|
||||
// alebo "/simple", ak to Nexus vyžaduje
|
||||
},
|
||||
"remoteEnv": {
|
||||
"DOCKER_BUILDKIT": "1"
|
||||
},
|
||||
"workspaceFolder": "/workspace",
|
||||
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind",
|
||||
"remoteUser": "root",
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"extensions": [
|
||||
"ms-python.python",
|
||||
"ms-python.vscode-pylance",
|
||||
"ms-toolsai.jupyter",
|
||||
"ms-python.black-formatter",
|
||||
"ms-python.isort",
|
||||
"ms-azuretools.vscode-docker"
|
||||
],
|
||||
"settings": {
|
||||
"[python]": {
|
||||
"editor.defaultFormatter": "ms-python.python"
|
||||
},
|
||||
"python.formatting.provider": "black",
|
||||
"python.analysis.extraPaths": [
|
||||
"/app"
|
||||
],
|
||||
"editor.formatOnSave": true,
|
||||
"python.defaultInterpreterPath": "/workspace/.venv/bin/python",
|
||||
"remote.restoreForwardedPorts": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"mounts": [
|
||||
"type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock"
|
||||
],
|
||||
"postCreateCommand": "bash .devcontainer/post_create.sh",
|
||||
"forwardPorts": [
|
||||
// 8000,
|
||||
// 8080
|
||||
]
|
||||
}
|
||||
29
.devcontainer/post_create.sh
Normal file
29
.devcontainer/post_create.sh
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
VENV_PATH="/workspace/.venv"
|
||||
|
||||
# Ak venv neexistuje, vytvor ho a priprav pip
|
||||
if [ ! -d "$VENV_PATH" ]; then
|
||||
echo "Virtuálne prostredie neexistuje – vytváram..."
|
||||
python -m venv "$VENV_PATH"
|
||||
|
||||
echo "Aktivujem virtuálne prostredie..."
|
||||
# shellcheck disable=SC1090
|
||||
source "$VENV_PATH/bin/activate"
|
||||
|
||||
echo "Aktualizujem pip a základné nástroje..."
|
||||
pip install --upgrade pip setuptools wheel
|
||||
else
|
||||
echo "Používam existujúce virtuálne prostredie..."
|
||||
# shellcheck disable=SC1090
|
||||
source "$VENV_PATH/bin/activate"
|
||||
fi
|
||||
|
||||
# Inštalácia závislostí, ak existuje requirements.txt
|
||||
if [ -f "/workspace/requirements.txt" ]; then
|
||||
echo "Inštalujem závislosti z requirements.txt..."
|
||||
pip install -r /workspace/requirements.txt
|
||||
else
|
||||
echo "requirements.txt nenájdený – preskakujem inštaláciu závislostí."
|
||||
fi
|
||||
Reference in New Issue
Block a user