Skip to content

Commit 2858be4

Browse files
authored
docker: speed up building, improve documentation (bitcoinops#2222)
* docker: avoid unnecessary cloning The user must already have the repo cloned to use the Dockerfile, so don't clone it again. This speeds up the building process by avoiding unnecessary operations and improving caching. * docker: make caching more robust Best practice is to combine apt-get update and apt-get install in one command to prevent caching issues. See https://docs.docker.com/build/building/best-practices/#apt-get * docker: improve README Elaborate a bit more on the fact that manually rebuilding is typically not necessary. Also remove the now deprecated docker-compose (V1) and replace it with docker compose (v2).
1 parent bc46407 commit 2858be4

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

Dockerfile

+8-11
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
11
# Use an official Ruby runtime as a parent image
22
FROM ruby:2.6.4
33

4-
# Set the working directory in the container
5-
WORKDIR /usr/src/app
6-
7-
# Clone the bitcoinops.github.io repository
8-
RUN git clone https://github.com/bitcoinops/bitcoinops.github.io.git
9-
10-
# Change to the repository directory
11-
WORKDIR /usr/src/app/bitcoinops.github.io
12-
134
# Install program to configure locales
14-
RUN apt-get update
15-
RUN apt-get install -y locales
5+
RUN apt-get update && \
6+
apt-get install -y locales
167
RUN dpkg-reconfigure locales && \
178
locale-gen C.UTF-8 && \
189
/usr/sbin/update-locale LANG=C.UTF-8
@@ -26,6 +17,12 @@ ENV LC_ALL C.UTF-8
2617
ENV LANG en_US.UTF-8
2718
ENV LANGUAGE en_US.UTF-8
2819

20+
# Set the working directory
21+
WORKDIR /usr/src/app
22+
23+
# Copy just the Gemfile and Gemfile.lock first to leverage Docker cache
24+
COPY Gemfile Gemfile.lock ./
25+
2926
# Install any needed gems specified in Gemfile
3027
RUN bundle install
3128

README.md

+16-5
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,25 @@ site an unlimited number of times with no extra work.
2626

2727
**Docker**
2828

29-
Ensure docker and docker-compose are installed. Run the command in the project
30-
directory.
29+
Using Docker eliminates the need for local Ruby installation and
30+
simplifies the setup process. Ensure Docker and Docker Compose are
31+
installed, then run the following command in the project directory:
3132

32-
docker-compose up --build
33+
docker compose up
3334

34-
To restart (in the event of code change).
35+
This will build the Docker image if needed and start the Jekyll server.
36+
The site preview will be available at http://localhost:4000.
3537

36-
docker-compose down -v && docker-compose up --build
38+
For most code changes, Jekyll's live reload will automatically update
39+
the preview. You only need to restart the container when making changes
40+
such as:
41+
42+
- Changing dependencies in the Gemfile
43+
- Modifying Docker configuration files
44+
45+
To rebuild and restart the container:
46+
47+
docker compose down && docker compose up --build
3748

3849
##### Install The Dependencies
3950

docker-compose.yml

-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@ services:
77
- "4000:4000"
88
volumes:
99
- .:/usr/src/app
10-
working_dir: /usr/src/app
1110
command: make preview

0 commit comments

Comments
 (0)