Skip to content

Instantly share code, notes, and snippets.

@sullemanhossam
Created June 28, 2024 02:02
Show Gist options
  • Save sullemanhossam/d195d6cbc4393e42ecda89e3977b6825 to your computer and use it in GitHub Desktop.
Save sullemanhossam/d195d6cbc4393e42ecda89e3977b6825 to your computer and use it in GitHub Desktop.
# Use the official Python base image
FROM python:3.8-slim
# Set environment variables
ENV HUGO_VERSION=0.111.2
# Install necessary dependencies
RUN apt-get update && \
apt-get install -y wget nodejs npm dpkg git make python3 rsync python3-pip python3-venv && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# Upgrade pip, setuptools, and wheel
RUN pip3 install --upgrade pip setuptools wheel
# Set the working directory
WORKDIR /workspace
# Copy the current directory contents into the container at /workspace
COPY . /workspace
# Install Hugo based on architecture
RUN ARCH=$(dpkg --print-architecture) && \
if [ "$ARCH" = "arm64" ]; then \
wget -O /tmp/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-arm64.deb; \
else \
wget -O /tmp/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb; \
fi && \
dpkg -i /tmp/hugo.deb && \
rm /tmp/hugo.deb
# Install Python dependencies
RUN pip3 install -no-cache-dir --r requirements.txt
# Run make all to build the site
RUN make all
# Expose the port the server will run on
EXPOSE 8000
# Command to serve the static files
CMD ["python3", "-m", "http.server", "8000", "--directory", "/workspace/public"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment