Skip to content
Merged
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
74 changes: 59 additions & 15 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,64 @@
# Use Ubuntu 24.04 LTS as the base image
FROM ubuntu:20.04 as base
FROM python:3.11-slim AS base
LABEL maintainer="emilcode-dev"

# Set DEBIAN_FRONTEND to noninteractive to avoid interactive prompts
ENV DEBIAN_FRONTEND=noninteractive
# poetry
# https://python-poetry.org/docs/configuration/#using-environment-variables
ENV POETRY_VERSION=2.1.2 \
POETRY_HOME="/opt/poetry" \
# do not ask any interactive question
POETRY_NO_INTERACTION=1

# Update the package list and install dev tools
RUN apt-get update && apt-get install -y --no-install-recommends\
python3 \
python3-pip \
&& rm -rf /var/lib/apt/lists/*
ENV PATH="$POETRY_HOME/bin:$PATH"

# Development stage
FROM base as dev
# Install system dependencies and Poetry
RUN apt-get update && apt-get install -y --no-install-recommends \
curl build-essential && \
rm -rf /var/lib/apt/lists/*

RUN apt-get update && apt-get install -y --no-install-recommends\
git \
&& rm -rf /var/lib/apt/lists/* \
&& python3 -m pip install --upgrade pip
# install poetry - respects $POETRY_VERSION & $POETRY_HOME
RUN curl -sSL https://install.python-poetry.org | python3 -

# -------- Builder stage --------
# FROM base AS builder

# WORKDIR /app
# COPY pyproject.toml poetry.lock LICENSE README.md ./

# # Install only runtime dependencies (without dev dependencies)
# RUN poetry config virtualenvs.create false && \
# poetry install --only main --no-root

# -------- Development stage --------
FROM base AS development

# Additional dev tooling (e.g. Git, etc.)
RUN apt-get update && apt-get install -y --no-install-recommends \
git && \
rm -rf /var/lib/apt/lists/*

WORKDIR /app

# COPY pyproject.toml poetry.lock LICENSE README.md ./
# RUN poetry install with dev --no-root

# CMD to launch bash in the dev container
CMD ["bash"]

# -------- Production stage --------
# FROM python:3.12-slim AS production

# # Copy runtime dependencies from builder
# COPY --from=builder /usr/local/lib/python3.12 /usr/local/lib/python3.12
# COPY --from=builder /usr/local/bin /usr/local/bin

# WORKDIR /app

# # Copy application code
# COPY . .

# # Use non-root user for security
# RUN adduser --disabled-password --gecos '' appuser && chown -R appuser /app
# USER appuser

# CMD ["python", "main.py"]

4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"build": {
"dockerfile": "Dockerfile",
"context": "..",
"target": "dev"
"target": "development"
},
"customizations": {
"vscode": {
Expand All @@ -23,6 +23,6 @@
}
}
},
"postCreateCommand": "python3 -m pip install -e \".[dev]\" && echo 'datawise-decisions dev container is ready!'"
"postCreateCommand": "poetry install -E dev && echo 'datawise-decisions dev container is ready!'"
}

2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
- name: Run inside Dev Container
uses: devcontainers/ci@v0.3
with:
runCmd: pytest
runCmd: poetry run pytest
Loading