feat: Add Docker for code debugging (#927)

* Update Dockerfile and docker-compose.yml

* Add Dockerfile for code debugging.
Add installation procedures of python, cpp and java.
This commit is contained in:
Yudong Jin 2023-11-08 03:20:29 +08:00 committed by GitHub
parent f0c81ce048
commit d5ee877fd8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 50 additions and 6 deletions

View file

@ -1,13 +1,14 @@
FROM python:3.9.0-alpine
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade pip
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple mkdocs-material==9.4.1 mkdocs-glightbox
ENV PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install --upgrade pip
RUN pip install mkdocs-material==9.4.1 mkdocs-glightbox
WORKDIR /app
WORKDIR /hello-algo
COPY docs /app/build/docs
COPY overrides /app/build/overrides
COPY mkdocs.yml /app/mkdocs.yml
COPY docs ./build/docs
COPY overrides ./build/overrides
COPY mkdocs.yml ./mkdocs.yml
RUN mkdocs build

33
codes/Dockerfile Normal file
View file

@ -0,0 +1,33 @@
FROM ubuntu:latest
# Use Ubuntu image from Aliyun
RUN sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list && \
sed -i 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list && \
sed -i 's/ports.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list
RUN apt-get update
# 设置需要安装的语言,使用空格隔开
# Set the languages to be installed, separated by spaces
ARG LANGS="python cpp"
# Available languagespython cpp java
RUN for LANG in $LANGS; do \
case "$LANG" in \
python) \
apt-get install -y python3.10 && \
update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1 ;; \
cpp) \
apt-get install -y g++ gdb ;; \
java) \
apt-get install -y openjdk-17-jdk ;; \
# More languages...
*) \
echo "Warning: No installation workflow for $LANG" ;; \
esac \
done
WORKDIR /codes
COPY ./ ./
CMD ["/bin/bash"]

8
codes/docker-compose.yml Normal file
View file

@ -0,0 +1,8 @@
version: '3.8'
services:
hello-algo-code:
build: .
image: hello-algo-code
container_name: hello-algo-code
stdin_open: true
tty: true

View file

@ -2,5 +2,7 @@ version: '3'
services:
hello-algo:
build: .
image: hello-algo
container_name: hello-algo
ports:
- "8000:8000"