Spaces:
Sleeping
Sleeping
| # Use an official Python runtime as the base image (for OS utilities) | |
| FROM python:3.9-slim | |
| # Set environment variables | |
| ENV LANG C.UTF-8 | |
| ENV GO_VERSION 1.23.0 | |
| ENV HUGO_VERSION latest | |
| # Install system dependencies, including Hugo and its requirements | |
| 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 the Hugo theme and all project files into the container | |
| COPY ./app/themes/hugo-theme-stack /app/themes/hugo-theme-stack | |
| COPY . . | |
| # Ensure the /app directory (and its subdirectories) are writable | |
| RUN chmod -R 777 /app | |
| RUN chmod u+w /app/.hugo_build.lock | |
| # Remove any stale Hugo build lock file | |
| RUN rm -f /app/.hugo_build.lock | |
| WORKDIR /app | |
| RUN mkdir -p /app && chown -R hugo:hugo /app | |
| USER hugo | |
| # (Optional) If you use Hugo Modules, refresh them: | |
| RUN hugo --ignoreCache && hugo mod clean && hugo mod get | |
| # Build the Hugo site with --noTimes to avoid file time updates | |
| RUN rm -f /app/.hugo_build.lock && hugo --noTimes | |
| # Expose the port the Hugo server will use | |
| EXPOSE 7860 | |
| # Start the Hugo server with --noTimes (and other desired flags) | |
| CMD ["hugo", "server", "--bind", "0.0.0.0", "--port", "7860", "--disableFastRender", "--noTimes"] | |