added scripts for docker vscode environment
							parent
							
								
									4590ba367b
								
							
						
					
					
						commit
						d47f912d28
					
				@ -0,0 +1,39 @@
 | 
			
		||||
FROM pytorch/pytorch:2.5.1-cuda12.4-cudnn9-runtime
 | 
			
		||||
ENV TZ=Europe/Samara
 | 
			
		||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
 | 
			
		||||
 | 
			
		||||
ARG USER
 | 
			
		||||
ARG GROUP
 | 
			
		||||
ARG UID
 | 
			
		||||
ARG GID
 | 
			
		||||
 | 
			
		||||
RUN apt update
 | 
			
		||||
RUN apt install sudo -y
 | 
			
		||||
RUN sed -i 's/^%sudo.*/%sudo   ALL=(ALL) NOPASSWD: ALL/' /etc/sudoers
 | 
			
		||||
 | 
			
		||||
RUN groupadd --gid ${GID} ${GROUP}
 | 
			
		||||
RUN useradd --shell /bin/bash --uid ${UID} --gid ${GID} -G sudo --create-home ${USER}
 | 
			
		||||
RUN mkdir /wd
 | 
			
		||||
RUN chown ${USER}:${GROUP} /wd
 | 
			
		||||
 | 
			
		||||
# SYSTEM CONFIGURATION
 | 
			
		||||
RUN apt install vim htop mc curl wget git tree -y
 | 
			
		||||
RUN curl -fsSL https://code-server.dev/install.sh | sh
 | 
			
		||||
RUN /opt/conda/bin/conda install -n base ipykernel --update-deps --force-reinstall -y
 | 
			
		||||
 | 
			
		||||
USER ${USER}
 | 
			
		||||
 | 
			
		||||
# USER CONFIGURATION
 | 
			
		||||
# RUN ...
 | 
			
		||||
 | 
			
		||||
RUN openssl req -x509 -newkey rsa:4096 -keyout /home/${USER}/key.pem -out /home/${USER}/cert.pem -sha256 -nodes -days 365 -subj "/C=RU/ST=SamaraRegion/L=Samara/O=SSAU/OU=LIAV/CN=vscode.ssau.ru/"
 | 
			
		||||
RUN mkdir -p /home/${USER}/.config/code-server
 | 
			
		||||
RUN echo 'bind-addr: 0.0.0.0:8443' >> /home/${USER}/.config/code-server/config.yaml
 | 
			
		||||
RUN echo "cert: /home/${USER}/cert.pem" >> /home/${USER}/.config/code-server/config.yaml
 | 
			
		||||
RUN echo "cert-key: /home/${USER}/key.pem" >> /home/${USER}/.config/code-server/config.yaml
 | 
			
		||||
 | 
			
		||||
RUN code-server --install-extension ms-python.python 
 | 
			
		||||
 | 
			
		||||
ENV SHELL=/bin/bash
 | 
			
		||||
SHELL ["/bin/bash", "--login", "-i", "-c"]
 | 
			
		||||
WORKDIR /wd
 | 
			
		||||
@ -0,0 +1,8 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
CURDIRNAME=${PWD##*/}
 | 
			
		||||
 | 
			
		||||
docker build . -t ${USER}_${CURDIRNAME}_vscode \
 | 
			
		||||
	--build-arg USER=${USER} \
 | 
			
		||||
	--build-arg GROUP=${USER} \
 | 
			
		||||
	--build-arg UID=$(id -u ${USER}) \
 | 
			
		||||
	--build-arg GID=$(id -g ${USER})
 | 
			
		||||
@ -0,0 +1,26 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
CURDIRNAME=${PWD##*/}
 | 
			
		||||
 | 
			
		||||
VSCODE_PORT=8400
 | 
			
		||||
YOURAPP_INSIDE_DOCKER_PORT=24000
 | 
			
		||||
PASSWORD=$(openssl rand -base64 45)
 | 
			
		||||
docker run \
 | 
			
		||||
	-d \
 | 
			
		||||
	--rm \
 | 
			
		||||
	--gpus "device=0" \
 | 
			
		||||
	-p ${VSCODE_PORT}:8443 \
 | 
			
		||||
	-p ${YOURAPP_INSIDE_DOCKER_PORT}:7443 \
 | 
			
		||||
	-v $(pwd):/wd \
 | 
			
		||||
	-v /home/${USER}/.ssh/:/home/${USER}/.ssh/:ro \
 | 
			
		||||
	--shm-size=10gb \
 | 
			
		||||
	--name ${USER}_${CURDIRNAME}_vscode \
 | 
			
		||||
	-e PASSWORD="${PASSWORD}" \
 | 
			
		||||
	${USER}_${CURDIRNAME}_vscode \
 | 
			
		||||
	code-server 
 | 
			
		||||
sleep 1
 | 
			
		||||
docker logs ${USER}_${CURDIRNAME}_vscode
 | 
			
		||||
echo ""
 | 
			
		||||
echo "Address: https://$(hostname -i | awk '{ print $1; }'):${VSCODE_PORT}"
 | 
			
		||||
echo "Password: $PASSWORD"
 | 
			
		||||
echo "" 
 | 
			
		||||
echo "You can use this port for application you develop: $YOURAPP_INSIDE_DOCKER_PORT" 
 | 
			
		||||
					Loading…
					
					
				
		Reference in New Issue