Skip to content

Commit 9639cbc

Browse files
authored
Merge pull request academicpages#2441 from abcsds/master
Add a dockerfile
2 parents 0d4e024 + 40e3c2b commit 9639cbc

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

Dockerfile

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Base image: Ruby with necessary dependencies for Jekyll
2+
FROM ruby:3.2
3+
4+
# Install dependencies
5+
RUN apt-get update && apt-get install -y \
6+
build-essential \
7+
nodejs \
8+
&& rm -rf /var/lib/apt/lists/*
9+
10+
# Set the working directory inside the container
11+
WORKDIR /usr/src/app
12+
13+
# Copy Gemfile and Gemfile.lock into the container (necessary for `bundle install`)
14+
COPY Gemfile Gemfile.lock ./
15+
16+
# Install bundler and dependencies
17+
RUN gem install bundler:2.3.26 && bundle install
18+
19+
# Expose port 4000 for Jekyll server
20+
EXPOSE 4000
21+
22+
# Command to serve the Jekyll site
23+
CMD ["bundle", "exec", "jekyll", "serve", "--host", "0.0.0.0", "--watch"]
24+

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@ When you are initially working your website, it is very useful to be able to pre
3535

3636
If you are running on Linux it may be necessary to install some additional dependencies prior to being able to run locally: `sudo apt install build-essential gcc make`
3737

38+
## Using docker
39+
40+
Working from a different OS, or just want to avoid installing dependencies? You can use the provided Dockerfile to build a container that will run the site for you.
41+
42+
Build the container:
43+
```bash
44+
docker build -t jekyll-site .
45+
```
46+
47+
Run the container:
48+
```bash
49+
docker run -p 4000:4000 --rm -v $(pwd):/usr/src/app jekyll-site
50+
```
51+
3852
# Maintenance
3953

4054
Bug reports and feature requests to the template should be [submitted via GitHub](https://github.com/academicpages/academicpages.github.io/issues/new/choose). For questions concerning how to style the template, please feel free to start a [new discussion on GitHub](https://github.com/academicpages/academicpages.github.io/discussions).

0 commit comments

Comments
 (0)