Created
October 29, 2025 05:22
-
-
Save rambalachandran/32394d71a71c6e1fc8f6efd7688521dc to your computer and use it in GitHub Desktop.
AWS Linux Docker With uv Python
This file contains hidden or 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 public.ecr.aws/amazonlinux/amazonlinux:2023-minimal | |
| # Install Python and required dependencies including build tools | |
| RUN dnf update -y && \ | |
| dnf install -y python3 python3-devel shadow-utils gcc gcc-c++ curl-minimal tar && \ | |
| dnf clean all | |
| # App user (non-root) and application directory | |
| RUN groupadd -g 1000 app && useradd -u 1000 -g app -m -s /sbin/nologin app && \ | |
| mkdir -p /app && chown app:app /app | |
| WORKDIR /app | |
| # Install uv (fast Python package manager) and create virtual environment | |
| RUN curl -LsSf https://astral.sh/uv/install.sh | env UV_INSTALL_DIR=/usr/local/bin sh && \ | |
| uv venv /opt/venv | |
| ENV VIRTUAL_ENV=/opt/venv | |
| ENV PATH="$VIRTUAL_ENV/bin:/usr/local/bin:${PATH}" | |
| # Copy requirements and install dependencies via uv | |
| COPY requirements.txt . | |
| RUN uv pip install --python /opt/venv/bin/python --no-cache-dir -r requirements.txt && \ | |
| chown -R app:app /opt/venv | |
| # Copy app code with correct ownership | |
| COPY --chown=app:app app/ ./ | |
| USER app | |
| # Set PYTHONPATH to include current directory | |
| ENV PYTHONPATH=/app | |
| ENTRYPOINT ["python3", "main.py"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment