Skip to content

Commit 3ba1b24

Browse files
committed
chore(devcontainer): create a non-root user
1 parent 913919f commit 3ba1b24

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

.devcontainer/Dockerfile

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
FROM python:3.11
22

3+
ENV PYTHONDONTWRITEBYTECODE=1 \
4+
PYTHONUNBUFFERED=1 \
5+
USER=compiler
6+
7+
RUN useradd --create-home --shell /bin/bash $USER && \
8+
chown -R $USER /home/$USER
9+
10+
WORKDIR /home/$USER/site
11+
312
RUN apt-get update
413
RUN apt-get install -y ruby-full && gem install bundler
514
RUN python -m pip install --upgrade pip
6-
715
COPY Gemfile Gemfile
816
COPY Gemfile.lock Gemfile.lock
917
RUN bundle install
1018

1119
COPY .devcontainer/requirements.txt .devcontainer/requirements.txt
1220
RUN pip install --no-cache-dir -r .devcontainer/requirements.txt
21+
22+
USER $USER
23+
ENV PATH "$PATH:/home/$USER/.local/bin"

.devcontainer/devcontainer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "compiler.la",
33
"dockerComposeFile": "docker-compose.yaml",
44
"service": "site",
5-
"workspaceFolder": "/srv/jekyll",
5+
"workspaceFolder": "/home/compiler/site",
66
"postAttachCommand": ["/bin/bash", ".devcontainer/postAttach.sh"],
77
"customizations": {
88
"vscode": {

.devcontainer/docker-compose.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
version: '3'
1+
version: "3"
22
services:
33
site:
44
build:
55
context: ..
66
dockerfile: .devcontainer/Dockerfile
77
volumes:
8-
- ..:/srv/jekyll
8+
- ..:/home/compiler/site
99
command: sleep infinity

0 commit comments

Comments
 (0)