-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathDockerfile
More file actions
42 lines (32 loc) · 975 Bytes
/
Dockerfile
File metadata and controls
42 lines (32 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Base this image on the official Docker image for Ruby
FROM ruby:3.3
# Install Node.js (needed for some Jekyll plugins)
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get install -y nodejs && \
rm -rf /var/lib/apt/lists/*
# Install bundler
RUN gem install bundler
# Set working directory to project root
WORKDIR /site
# Smart entrypoint
COPY <<'EOF' /usr/local/bin/docker-entrypoint.sh
#!/bin/bash
set -e
# Only install/update if needed
if [ -f "Gemfile" ]; then
if ! bundle check > /dev/null 2>&1; then
echo "📦 Installing gems..."
bundle install
fi
fi
# Execute the main command
exec "$@"
EOF
# make the script executable
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# Expose Jekyll's default port
EXPOSE 4000
# Set the entrypoint to the script
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
# Default command
CMD ["bundle", "exec", "jekyll", "serve", "--host", "0.0.0.0", "--livereload", "--force_polling"]