Skip to content

Commit

Permalink
feat: update image pulling from hub
Browse files Browse the repository at this point in the history
  • Loading branch information
ljy2855 committed Nov 27, 2024
1 parent e73fb77 commit ec4c698
Showing 1 changed file with 6 additions and 64 deletions.
70 changes: 6 additions & 64 deletions start_pintos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,74 +3,16 @@
# ์‚ฌ์šฉ์ž์˜ ์ด๋ฆ„์ด๋‚˜ ๊ณ ์œ ํ•œ ๊ฐ’์„ ์‚ฌ์šฉํ•˜์—ฌ ์ปจํ…Œ์ด๋„ˆ ์ด๋ฆ„ ์„ค์ •
USER_NAME=$(whoami)
CONTAINER_NAME="pintos_${USER_NAME}"
DOCKERFILE_PATH="./Dockerfile.runner"
IMAGE_NAME="custom-pintos" # ์ƒˆ๋กœ ์ž‘์„ฑํ•œ ์ด๋ฏธ์ง€ ์ด๋ฆ„
IMAGE_NAME="cocopam/pintos-runner:latest" # Docker Hub์—์„œ ๊ฐ€์ ธ์˜ฌ ์ด๋ฏธ์ง€ ์ด๋ฆ„

# ํ˜ธ์ŠคํŠธ์˜ UID์™€ GID ๊ฐ€์ ธ์˜ค๊ธฐ
HOST_UID=$(id -u)
HOST_GID=$(id -g)

# Dockerfile ์ƒ์„ฑ
cat <<EOF > ${DOCKERFILE_PATH}
# ๋ฒ ์ด์Šค ์ด๋ฏธ์ง€๋กœ Ubuntu 18.04 ์‚ฌ์šฉ
FROM ubuntu:18.04
# ๋นŒ๋“œ ์ธ์ž: UID์™€ GID๋ฅผ ์Šคํฌ๋ฆฝํŠธ์—์„œ ์ „๋‹ฌ๋ฐ›์Œ
ARG UID
ARG GID
# ํ•„์š”ํ•œ ํŒจํ‚ค์ง€ ์„ค์น˜
RUN apt-get update \\
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \\
bash \\
build-essential \\
gdb \\
gcc \\
emacs \\
vim \\
nano \\
qemu \\
wget \\
xorg-dev \\
libncursesw5 \\
libncurses5-dev \\
dos2unix \\
expect \\
rsync \\
&& apt-get clean \\
&& rm -rf /var/lib/apt/lists/*
# ํ˜ธ์ŠคํŠธ ์‚ฌ์šฉ์ž์™€ ๋™์ผํ•œ UID/GID๋กœ ์‚ฌ์šฉ์ž ์ƒ์„ฑ
RUN groupadd -g \${GID} pintosgroup && \\
useradd -m -u \${UID} -g pintosgroup pintosuser
# Pintos ์†Œ์Šค ๋””๋ ‰ํ„ฐ๋ฆฌ ์ƒ์„ฑ
RUN mkdir -p /pintos/src
# ์ž‘์—… ๋””๋ ‰ํ„ฐ๋ฆฌ ์„ค์ •
WORKDIR /pintos
# ํ™˜๊ฒฝ ๋ณ€์ˆ˜ ์„ค์ •
ENV PINTOS_HOME=/pintos
ENV PATH=/pintos/src/utils:\$PATH
# ์‚ฌ์šฉ์ž ๊ถŒํ•œ ์„ค์ •
USER pintosuser
# ๊ธฐ๋ณธ ๋ช…๋ น
CMD ["bash"]
EOF

echo "Dockerfile ์ƒ์„ฑ ์™„๋ฃŒ."

# Docker ์ด๋ฏธ์ง€ ๋นŒ๋“œ
echo "Docker ์ด๋ฏธ์ง€๋ฅผ ๋นŒ๋“œํ•ฉ๋‹ˆ๋‹ค..."
docker build -t ${IMAGE_NAME} -f ${DOCKERFILE_PATH} --build-arg UID=${HOST_UID} --build-arg GID=${HOST_GID} .
# Docker Hub์—์„œ ์ด๋ฏธ์ง€ ๊ฐ€์ ธ์˜ค๊ธฐ
echo "Docker Hub์—์„œ ์ด๋ฏธ์ง€๋ฅผ ๊ฐ€์ ธ์˜ต๋‹ˆ๋‹ค: ${IMAGE_NAME}"
docker pull ${IMAGE_NAME}
if [ $? -ne 0 ]; then
echo "Docker ์ด๋ฏธ์ง€ ๋นŒ๋“œ์— ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค."
echo "Docker ์ด๋ฏธ์ง€๋ฅผ ๊ฐ€์ ธ์˜ค๋Š” ๋ฐ ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค."
exit 1
fi
echo "Docker ์ด๋ฏธ์ง€(${IMAGE_NAME}) ๋นŒ๋“œ ์™„๋ฃŒ."
echo "Docker ์ด๋ฏธ์ง€(${IMAGE_NAME}) ๊ฐ€์ ธ์˜ค๊ธฐ ์™„๋ฃŒ."

# ๊ธฐ์กด ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ์žˆ๋‹ค๋ฉด ์‚ญ์ œ
EXISTING_CONTAINER=$(docker ps -a --filter "name=${CONTAINER_NAME}" --format "{{.ID}}")
Expand Down

0 comments on commit ec4c698

Please sign in to comment.