Skip to content

Commit 0778a24

Browse files
authored
Merge pull request #2981 from adriandavidauer/fix_docker
added chmod to docu and connection_pool to gemfile, added VS Code container (close #2443)
2 parents 31bdab4 + 81b71e3 commit 0778a24

File tree

5 files changed

+44
-5
lines changed

5 files changed

+44
-5
lines changed

.devcontainer/devcontainer.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "ACADEMIC PAGES",
3+
"dockerComposeFile": "../docker-compose.yaml",
4+
"service": "jekyll-site",
5+
"remoteEnv": {
6+
"VSCODE_SERVER_DIR": "/home/vscode/.vscode-server"
7+
},
8+
"runArgs": [
9+
"--user",
10+
"1000:1000"
11+
],
12+
"workspaceFolder": "/usr/src/app",
13+
"remoteUser": "vscode",
14+
"forwardPorts": [4000] // Add port forwarding
15+
}

Dockerfile

100644100755
Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,29 @@ RUN apt-get update && apt-get install -y \
77
nodejs \
88
&& rm -rf /var/lib/apt/lists/*
99

10-
# Set the working directory inside the container
10+
11+
# Create a non-root user with UID 1000
12+
RUN groupadd -g 1000 vscode && \
13+
useradd -m -u 1000 -g vscode vscode
14+
15+
# Set the working directory
1116
WORKDIR /usr/src/app
1217

18+
# Set permissions for the working directory
19+
RUN chown -R vscode:vscode /usr/src/app
20+
21+
# Switch to the non-root user
22+
USER vscode
23+
1324
# Copy Gemfile into the container (necessary for `bundle install`)
1425
COPY Gemfile ./
1526

27+
28+
1629
# Install bundler and dependencies
17-
RUN gem install bundler:2.3.26 && bundle install
30+
RUN gem install connection_pool:2.5.0
31+
RUN gem install bundler:2.3.26
32+
RUN bundle install
1833

1934
# Command to serve the Jekyll site
2035
CMD ["jekyll", "serve", "-H", "0.0.0.0", "-w", "--config", "_config.yml,_config_docker.yml"]

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ group :jekyll_plugins do
1010
end
1111

1212
gem 'github-pages'
13+
gem 'connection_pool', '2.5.0'

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ See more info at https://academicpages.github.io/
2020
When you are initially working on your website, it is very useful to be able to preview the changes locally before pushing them to GitHub. To work locally you will need to:
2121

2222
1. Clone the repository and made updates as detailed above.
23+
24+
### Using a different IDE
2325
1. Make sure you have ruby-dev, bundler, and nodejs installed
2426

2527
On most Linux distribution and [Windows Subsystem Linux](https://learn.microsoft.com/en-us/windows/wsl/about) the command is:
@@ -59,11 +61,16 @@ Working from a different OS, or just want to avoid installing dependencies? You
5961
You can build and execute the container by running the following command in the repository:
6062
6163
```bash
64+
chmod -R 777 .
6265
docker compose up
6366
```
6467
6568
You should now be able to access the website from `localhost:4000`.
6669
70+
### Using the DevContainer in VS Code
71+
72+
If you are using [Visual Studio Code](https://code.visualstudio.com/) you can use the [Dev Container](https://code.visualstudio.com/docs/devcontainers/containers) that comes with this Repository. Normally VS Code detects that a development coontainer configuration is available and asks you if you want to use the container. If this doesn't happen you can manually start the container by **F1->DevContainer: Reopen in Container**. This restarts your VS Code in the container and automatically hosts your academic page locally on http://localhost:4000. All changes will be updated live to that page after a few seconds.
73+
6774
# Maintenance
6875
6976
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).

docker-compose.yaml

100644100755
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ services:
22
jekyll-site:
33
image: jekyll-site
44
build: .
5-
volumes: [.:/usr/src/app]
6-
ports: [4000:4000]
5+
volumes: [ .:/usr/src/app ]
6+
ports: [ 4000:4000 ]
77
user: 1000:1000
8-
environment: [JEKYLL_ENV=docker]
8+
environment: [ JEKYLL_ENV=docker ]
9+
command: jekyll serve -H 0.0.0.0 -w --config _config.yml, _config_docker.yml

0 commit comments

Comments
 (0)