Skip to content

Commit

Permalink
Added Robust Node.js and npm Installation:
Browse files Browse the repository at this point in the history
Installed Node.js 20 via NodeSource to ensure compatibility with code-server.
Cleaned the npm cache and removed previous code-server installations to avoid conflicts.
Permission Fixes:
Used the --unsafe-perm flag during npm installation to resolve permission-related issues.
Improved Cleanup:
Removed unnecessary cached files to reduce the Docker image size.
Fallback-Ready and Optimized:
Prepared the Dockerfile to cleanly handle code-server npm installation issues.
  • Loading branch information
dereckmezquita committed Dec 5, 2024
1 parent 22b28f3 commit c697c89
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM ubuntu:22.04

# Environment variables
# Environment variables for container configuration
ARG USERNAME=developer
ARG PASSWORD=password
ARG PORT=8443

# Install essential tools
# Update and install essential tools
RUN apt-get update && apt-get install -y \
build-essential \
curl \
Expand All @@ -21,20 +21,22 @@ RUN apt-get update && apt-get install -y \
gnupg \
&& rm -rf /var/lib/apt/lists/*

# Install Node.js and npm for arm/v7 compatibility with code-server
# Install Node.js and npm (required for code-server npm installation)
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get install -y nodejs && \
npm install -g npm@latest
apt-get install -y nodejs

# Ensure the installation environment is clean and ready
RUN npm cache clean --force && \
rm -rf /usr/lib/node_modules/code-server

# Install code-server globally using npm with proper permissions
RUN npm install -g --unsafe-perm code-server

# Add entrypoint script
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

# Install code-server with --unsafe-perm to fix permission issues
RUN curl -fsSL https://code-server.dev/install.sh | bash || \
npm install -g --unsafe-perm code-server

# Create a non-root user
# Create a non-root user and configure environment
RUN useradd -ms /bin/bash -G sudo $USERNAME && \
echo "$USERNAME:$PASSWORD" | chpasswd && \
mkdir -p /home/$USERNAME && \
Expand Down

0 comments on commit c697c89

Please sign in to comment.