Skip to content

Commit

Permalink
Merge pull request #2797 from non-det-alle/docker-fix
Browse files Browse the repository at this point in the history
Fix running locally with Docker
  • Loading branch information
rjzupkoii authored Feb 1, 2025
2 parents d021750 + cd9f918 commit e53c946
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 52 deletions.
5 changes: 1 addition & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ COPY Gemfile ./
# Install bundler and dependencies
RUN gem install bundler:2.3.26 && bundle install

# Expose port 4000 for Jekyll server
EXPOSE 4000

# Command to serve the Jekyll site
CMD ["bundle", "exec", "jekyll", "serve", "--host", "0.0.0.0", "--watch"]
CMD ["jekyll", "serve", "-H", "0.0.0.0", "-w", "--config", "_config.yml,_config_docker.yml"]

51 changes: 3 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,58 +41,13 @@ If you are running on Linux it may be necessary to install some additional depen

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.

Start by build the container:
You can build and execute the container by running the following command in the repository:

```bash
docker build -t jekyll-site .
docker compose up
```

Next, run the container:
```bash
docker run -p 4000:4000 --rm -v $(pwd):/usr/src/app jekyll-site
```

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:
### Steps for Windows:
1. **Check Docker Installation**: Ensure Docker is installed and running.
2. **Adjust Path for Volume Mapping**:
- On Windows, replace `$(pwd)` with the full absolute path to your current directory. For example:
```bash
-v C:\path\to\your\site:/usr/src/app
```
### Full Command Example:
```bash
docker run -p 4000:4000 --rm -v C:\path\to\your\site:/usr/src/app jekyll-site
```
### Things to Keep in Mind:
1. **Use PowerShell**:
- If you are using PowerShell, you can use `${PWD}` for the current directory:
```bash
docker run -p 4000:4000 --rm -v ${PWD}:/usr/src/app jekyll-site
```
2. **Enable Docker File Sharing**:
- If your volume doesn't map correctly, ensure Docker has access to the drive where your project resides. To do this:
- Open Docker Desktop.
- Go to *Settings**Resources**File Sharing*.
- Add your drive (e.g., `C:`).

3. **Run in Command Prompt or PowerShell**:
- In *Command Prompt*:

```bash
docker run -p 4000:4000 --rm -v C:\path\to\your\site:/usr/src/app jekyll-site
```
- In *PowerShell*:

```bash
docker run -p 4000:4000 --rm -v ${PWD}:/usr/src/app jekyll-site
```
You should now be able to access the website from `localhost:4000`.

# Maintenance

Expand Down
1 change: 1 addition & 0 deletions _config_docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
url: ""
8 changes: 8 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:
jekyll-site:
image: jekyll-site
build: .
volumes: [.:/usr/src/app]
ports: [4000:4000]
user: 1000:1000
environment: [JEKYLL_ENV=docker]

0 comments on commit e53c946

Please sign in to comment.