terminal2 / Dockerfile
tatoy's picture
Update Dockerfile
7af8cd3 verified
raw
history blame
1.28 kB
# Use Ubuntu as the base image
FROM ubuntu:latest
# Update package lists and install necessary packages
RUN apt-get update && apt-get install -y \
bash \
wget \
ca-certificates \
sudo
# Clean up APT when done
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Create /data directory and give permission to user 1001
RUN mkdir -p /data
# Download and install gotty
RUN wget -O gotty.tar.gz https://github.com/yudai/gotty/releases/download/v1.0.1/gotty_linux_amd64.tar.gz \
&& tar -xzvf gotty.tar.gz -C /usr/local/bin/ \
&& chmod +x /usr/local/bin/gotty \
&& rm gotty.tar.gz
# Create user 1001 and set working directory
RUN useradd -u 1001 -d /data user1001 \
&& echo 'user1001 ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/user1001 \
&& chmod 0440 /etc/sudoers.d/user1001
# Switch to user 1001
USER user1001
# Set working directory to /data
WORKDIR /data
# Change ownership of the /data folder
RUN chown -R user1001:user1001 /data
# Create .bashrc file and set PS1 environment variable
RUN echo 'PS1="online-terminal:\\w\\$ "' > /data/.bashrc
# Expose port
EXPOSE 8080
# Use gotty to run bash with the modified PS1 environment variable
CMD ["gotty", "--permit-write", "--port", "3000", "--permit-arguments", "/bin/bash", "--rcfile", "/data/.bashrc"]