Skip to content

Commit cd9f918

Browse files
committed
Fix running locally with Docker
1 parent 1acca92 commit cd9f918

File tree

4 files changed

+13
-52
lines changed

4 files changed

+13
-52
lines changed

Diff for: Dockerfile

+1-4
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ COPY Gemfile ./
1616
# Install bundler and dependencies
1717
RUN gem install bundler:2.3.26 && bundle install
1818

19-
# Expose port 4000 for Jekyll server
20-
EXPOSE 4000
21-
2219
# Command to serve the Jekyll site
23-
CMD ["bundle", "exec", "jekyll", "serve", "--host", "0.0.0.0", "--watch"]
20+
CMD ["jekyll", "serve", "-H", "0.0.0.0", "-w", "--config", "_config.yml,_config_docker.yml"]
2421

Diff for: README.md

+3-48
Original file line numberDiff line numberDiff line change
@@ -41,58 +41,13 @@ If you are running on Linux it may be necessary to install some additional depen
4141

4242
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 if you have [Docker](https://www.docker.com/) installed.
4343

44-
Start by build the container:
44+
You can build and execute the container by running the following command in the repository:
4545

4646
```bash
47-
docker build -t jekyll-site .
47+
docker compose up
4848
```
4949

50-
Next, run the container:
51-
```bash
52-
docker run -p 4000:4000 --rm -v $(pwd):/usr/src/app jekyll-site
53-
```
54-
55-
To run the `docker run` command on Windows, you need to adjust the syntax for the volume mapping (`-v`) as Windows uses different path formats. Here's how to run your command on Windows:
56-
57-
### Steps for Windows:
58-
1. **Check Docker Installation**: Ensure Docker is installed and running.
59-
2. **Adjust Path for Volume Mapping**:
60-
61-
- On Windows, replace `$(pwd)` with the full absolute path to your current directory. For example:
62-
63-
```bash
64-
-v C:\path\to\your\site:/usr/src/app
65-
```
66-
67-
### Full Command Example:
68-
```bash
69-
docker run -p 4000:4000 --rm -v C:\path\to\your\site:/usr/src/app jekyll-site
70-
```
71-
72-
### Things to Keep in Mind:
73-
1. **Use PowerShell**:
74-
- If you are using PowerShell, you can use `${PWD}` for the current directory:
75-
```bash
76-
docker run -p 4000:4000 --rm -v ${PWD}:/usr/src/app jekyll-site
77-
```
78-
79-
2. **Enable Docker File Sharing**:
80-
- If your volume doesn't map correctly, ensure Docker has access to the drive where your project resides. To do this:
81-
- Open Docker Desktop.
82-
- Go to *Settings**Resources**File Sharing*.
83-
- Add your drive (e.g., `C:`).
84-
85-
3. **Run in Command Prompt or PowerShell**:
86-
- In *Command Prompt*:
87-
88-
```bash
89-
docker run -p 4000:4000 --rm -v C:\path\to\your\site:/usr/src/app jekyll-site
90-
```
91-
- In *PowerShell*:
92-
93-
```bash
94-
docker run -p 4000:4000 --rm -v ${PWD}:/usr/src/app jekyll-site
95-
```
50+
You should now be able to access the website from `localhost:4000`.
9651

9752
# Maintenance
9853

Diff for: _config_docker.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
url: ""

Diff for: docker-compose.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
services:
2+
jekyll-site:
3+
image: jekyll-site
4+
build: .
5+
volumes: [.:/usr/src/app]
6+
ports: [4000:4000]
7+
user: 1000:1000
8+
environment: [JEKYLL_ENV=docker]

0 commit comments

Comments
 (0)