Spaces:
Sleeping
Sleeping
Create Dockerfile
Browse files- Dockerfile +53 -0
Dockerfile
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Use an official Python runtime as the base image (for OS utilities)
|
2 |
+
FROM python:3.9-slim
|
3 |
+
|
4 |
+
# Set environment variables
|
5 |
+
ENV LANG=C.UTF-8
|
6 |
+
ENV HUGO_VERSION=0.144.0
|
7 |
+
ENV HF_SPACE_URL="https://astraos-test.hf.space/"
|
8 |
+
|
9 |
+
# Install system dependencies, including Hugo
|
10 |
+
RUN apt-get update && apt-get install -y \
|
11 |
+
curl \
|
12 |
+
git \
|
13 |
+
build-essential \
|
14 |
+
gcc \
|
15 |
+
unzip \
|
16 |
+
ca-certificates \
|
17 |
+
libcurl4-openssl-dev \
|
18 |
+
libssl-dev && \
|
19 |
+
rm -rf /var/lib/apt/lists/*
|
20 |
+
|
21 |
+
# Install a specific version of Hugo
|
22 |
+
RUN curl -L https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_Linux-64bit.tar.gz \
|
23 |
+
| tar -xz -C /usr/local/bin
|
24 |
+
|
25 |
+
# Set working directory
|
26 |
+
WORKDIR /app
|
27 |
+
|
28 |
+
# Copy the Hugo theme and all project files into the container
|
29 |
+
COPY ./themes/hugo-brewm /app/themes/hugo-brewm
|
30 |
+
COPY . .
|
31 |
+
|
32 |
+
# Ensure the /app directory (and subdirectories) are writable
|
33 |
+
RUN chmod -R 777 /app
|
34 |
+
|
35 |
+
# Remove any stale Hugo build lock file
|
36 |
+
RUN rm -f /app/.hugo_build.lock
|
37 |
+
|
38 |
+
# Change ownership of /app to avoid permission issues
|
39 |
+
RUN useradd -m hugo && chown -R hugo:hugo /app
|
40 |
+
USER hugo
|
41 |
+
|
42 |
+
# Update Hugo modules
|
43 |
+
RUN hugo mod tidy
|
44 |
+
|
45 |
+
# Build the Hugo site with --noTimes
|
46 |
+
RUN hugo --noTimes
|
47 |
+
|
48 |
+
# Expose the port the Hugo server will use
|
49 |
+
EXPOSE 7860
|
50 |
+
|
51 |
+
# Start the Hugo server with --noTimes (and other flags)
|
52 |
+
CMD ["hugo", "server", "--bind", "0.0.0.0", "--port", "7860", "--appendPort=true", "--disableFastRender", "--noBuildLock", "--noTimes", "--bind=127.0.0.1", "baseURL=https://astraos-test.hf.space/"]
|
53 |
+
# CMD ["hugo", "server", "--bind", "0.0.0.0", "--port", "7860", "--appendPort=false", "--disableFastRender", "--noBuildLock", "--noTimes", "--bind=127.0.0.1"]
|