File size: 1,288 Bytes
4d89218 d6a8f33 f31dae0 4d89218 d6a8f33 1b93113 d6a8f33 f31dae0 4d89218 c45586e f31dae0 4d89218 d6a8f33 f31dae0 4d89218 c45586e d6a8f33 4d89218 c45586e d6a8f33 4d89218 d6a8f33 4d89218 c45586e d6a8f33 4d89218 d6a8f33 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# 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
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Disable 'no new privileges' flag
RUN echo 'Defaults !sysctl,!snap' > /etc/sudoers.d/no-new-privileges
# Create /data directory and give permission to user 1001
RUN mkdir -p /data && chown -R root:root /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 root -d /data userroot \
&& echo 'userroot ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/userroot \
&& chmod 0440 /etc/sudoers.d/userroot
# Switch to user 1001 and set working directory
USER ruut
WORKDIR /data
# Create .bashrc file and set PS1 environment variable
RUN echo 'PS1="online-terminal:\\w\\$ "' > /data/.bashrc
# Expose port
EXPOSE 3000
# Use gotty to run bash and modify PS1 environment variable
CMD ["gotty", "--permit-write", "--port", "3000", "--permit-arguments", "/bin/bash", "--rcfile", "/data/.bashrc"]
|