# Use a Node.js LTS Alpine image as the base
FROM hugomods/hugo:nightly

# Install Node.js and npm (needed for fetch-wordpress.js and sass)
RUN apk add --no-cache nodejs npm

# Install Sass (Dart Sass) globally
RUN npm install -g sass

# Set the working directory inside the container
WORKDIR /app

# Copy the entire project into the container
COPY . .

# Make the build script executable (if not already)
RUN chmod +x scripts/build.sh

# Install Node.js dependencies if any (e.g., for fetch-wordpress.js)
# Assuming package.json exists and has dependencies
RUN if [ -f package.json ]; then npm install; fi

# Ensure /usr/local/bin is in PATH for the CMD
ENV PATH="/usr/local/bin:$PATH"

# Command to run the build script when the container starts
CMD ["./scripts/build.sh"]
