dailydev.com / Dockerfile
AstraOS's picture
Update Dockerfile
aab59c9 verified
# Use an official Python runtime as the base image
FROM python:3.9-slim
# Install system dependencies, including Hugo and required libraries
RUN apt-get update && apt-get install -y \
curl \
git \
build-essential \
gcc \
unzip \
ca-certificates \
libcurl4-openssl-dev \
libssl-dev \
hugo \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
COPY ./app/themes/hugo-theme-stack /app/themes/hugo-theme-stack
# Copy the Hugo theme and all project files into the container
COPY . .
# Ensure Hugo has the right permissions
RUN chmod -R 777 /app
# Remove any stale Hugo build lock file
RUN rm -f /app/.hugo_build.lock
# Create a non-root user for security & set ownership
RUN useradd -m hugo && chown -R hugo:hugo /app
USER hugo
# Install Hugo modules if required
# RUN hugo mod clean && hugo mod get
# Build the Hugo site (no timestamps for consistency)
RUN hugo --noTimes
# Expose the port the Hugo server will use
EXPOSE 7860
# Start the Hugo server
CMD ["hugo", "server", "--bind", "0.0.0.0", "--port", "7860", "--disableFastRender", "--noBuildLock", "--noTimes"]