Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docker): enhance Dockerfile with caching and comments #614

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/.devcontainer
/.github
/tests
38 changes: 34 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,46 @@
FROM python:3-slim
# Use the Dockerfile syntax version 1.5 for enhanced features
# syntax=docker/dockerfile:1.5

# Start from a lightweight Python 3.12 image
FROM python:3.12-slim

# Set environment variables to control shell interaction and markdown formatting
# Disable shell interaction by default (not possible in docker)
ENV SHELL_INTERACTION=false

# Disable markdown prettification by default
ENV PRETTIFY_MARKDOWN=false

# Automatically detect the operating system name
ENV OS_NAME=auto

# Automatically detect the shell name
ENV SHELL_NAME=auto

# Set the DEBIAN_FRONTEND environment variable to noninteractive to suppress prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive

# Disable automatic clean-up of apt cache to retain downloaded packages
RUN rm /etc/apt/apt.conf.d/docker-clean && \
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache

# Update package lists and install the gcc compiler while caching the apt data
RUN --mount=type=cache,target=/var/cache/apt \
--mount=type=cache,target=/var/lib/apt \
apt-get update && apt-get install -y gcc

# Set the working directory to /app
WORKDIR /app
COPY . /app

RUN apt-get update && apt-get install -y gcc
RUN pip install --no-cache /app && mkdir -p /tmp/shell_gpt
# Copy the current directory contents into the /app directory in the container
COPY . .

# Install Python dependencies using pip while caching the pip data
RUN --mount=type=cache,target=/root/.cache/pip \
pip install /app

# Define a mount point for temporary files
VOLUME /tmp/shell_gpt

# Set the default command to run when the container starts
ENTRYPOINT ["sgpt"]