Skip to content

Commit 1e634a8

Browse files
committed
Fix for the permissons
1 parent b12c876 commit 1e634a8

File tree

2 files changed

+16
-29
lines changed

2 files changed

+16
-29
lines changed

.devcontainer/Dockerfile

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,22 @@
1-
# Use the official Go 1.24.5 image based on Debian Bookworm as the base
1+
# Go base image (Debian Bookworm)
22
FROM golang:1.24.5-bookworm
33

4-
# Update package lists and install system dependencies:
5-
# - Reinstall ca-certificates to ensure SSL works
6-
# - Install sudo for privilege escalation
7-
# - Install software-properties-common for repo management
8-
# - Install git for source control
4+
# Install common dev dependencies
95
RUN apt-get update && \
10-
apt-get -y install --reinstall ca-certificates && \
11-
apt-get -y install sudo \
12-
software-properties-common \
6+
apt-get -y install --no-install-recommends \
7+
sudo \
138
git \
14-
make
9+
make && \
10+
rm -rf /var/lib/apt/lists/*
1511

16-
# Set environment variables for the new non-root user
17-
ENV USER_NAME vscode
18-
ENV USER_PASSWORD password
12+
# Create non-root vscode user with sudo
13+
RUN useradd -ms /bin/bash vscode && \
14+
echo "vscode ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/vscode
1915

20-
# Create a new user with bash as the shell, disabled password initially
21-
RUN adduser --quiet --disabled-password --shell /bin/bash --home /home/$USER_NAME --gecos "User" $USER_NAME
16+
# Fix Go build cache permissions
17+
RUN mkdir -p /home/vscode/.cache/go-build && \
18+
chown -R vscode:vscode /home/vscode/.cache
2219

23-
# Set password for the new user and add them to the sudo group
24-
RUN echo "${USER_NAME}:${USER_PASSWORD}" | chpasswd && usermod -aG sudo $USER_NAME
25-
26-
# Configure passwordless sudo for the new user
27-
RUN echo $USER_NAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USER_NAME && chmod 0440 /etc/sudoers.d/$USER_NAME
28-
29-
# Set HOME env variable for the new user
30-
ENV HOME /home/$USER_NAME
31-
32-
# Switch to the non-root user
33-
USER $USER_NAME
34-
35-
# Set working directory to the user's home directory
36-
WORKDIR /home/$USER_NAME
20+
# Switch to vscode user
21+
USER vscode
22+
WORKDIR /workspaces

.github/workflows/devcontainer.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ jobs:
1818
runCmd: |
1919
go version
2020
go build ./...
21+

0 commit comments

Comments
 (0)