Skip to content

Commit

Permalink
add Dockerfile of OS Image
Browse files Browse the repository at this point in the history
This Dockerfile is used to build the os image using apt, such as debian/ubuntu/kali-linux, etc.
  • Loading branch information
seeleclover authored Apr 15, 2024
1 parent 3ecb96b commit e39db2d
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# docker-images
58 changes: 58 additions & 0 deletions os/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
######################################################
# ImageName : Operation System Image
# Platform : amd64, arm64
# Author : Seele.Clover
# Copyright (c) 2024 by GDMU-NA, All Rights Reserved.
######################################################

# this Dockerfile is used to build the os image using apt, such as debian/ubuntu/kali-linux, etc.

ARG SYSTEM_IMAGE
ARG SYSTEM_VERSION
FROM ${SYSTEM_IMAGE}:${SYSTEM_VERSION} as system

LABEL org.opencontainers.image.name=${SYSTEM_IMAGE} \
org.opencontainers.image.version=${SYSTEM_VERSION} \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.maintainer="Seele.Clover" \
org.opencontainers.image.vendor="GDMU-NA" \
org.opencontainers.image.repository="https://github.com/gdmuna/docker-images" \
org.opencontainers.image.url="https://hub.docker.com/r/gdmuna/docker-images"

EXPOSE 22
ENV LANG=C.UTF-8 \
TZ=Asia/Shanghai

WORKDIR /root

COPY --chown=root:root ./motd /etc/
COPY --chown=root:root ./init/* /root/init/

RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
# allow apt to work with https-based sources
&& apt-get install -y --no-install-recommends ca-certificates \
&& chmod +x /root/init/setAptSource.sh \
# add timezone setting
&& apt-get install -y tzdata \
&& echo "${TZ}" > /etc/timezone && ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime \
&& dpkg-reconfigure --frontend noninteractive tzdata \
# add ssh service
&& apt-get install -y --no-install-recommends openssh-server \
&& sed -i "/PermitRootLogin prohibit-password/a\PermitRootLogin yes" /etc/ssh/sshd_config \
&& chmod +x /root/init/setRootPassword.sh \
# obtain the env of the container itself from 1st process and set it as the env of ssh
&& echo '' >> /etc/profile \
&& echo 'export $(cat /proc/1/environ | tr "\\0" "\\n" | xargs)' >> /etc/profile \
&& echo '' >> /root/.bashrc \
&& echo 'source /etc/profile' >> /root/.bashrc \
# add common tools
&& apt-get install -y --no-install-recommends vim \
&& apt-get install -y --no-install-recommends htop \
&& apt-get install -y --no-install-recommends curl wget \
&& apt-get install -y --no-install-recommends iproute2 iputils-ping traceroute \
# clean up cache
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

CMD ["/bin/bash", "-c", "/etc/init.d/ssh start && tail -f /dev/null"]
8 changes: 8 additions & 0 deletions os/init/setAptSource.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

# ubuntu amd64
cp -a /etc/apt/sources.list /etc/apt/sources.list.bak \
# change apt source to ustc
&& sed -i "s@http://.*archive.ubuntu.com@https://mirrors.ustc.edu.cn@g" /etc/apt/sources.list \
&& sed -i "s@http://.*security.ubuntu.com@https://mirrors.ustc.edu.cn@g" /etc/apt/sources.list \
&& apt-get update
4 changes: 4 additions & 0 deletions os/init/setRootPassword.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

PASSWORD=$1
echo "root:$PASSWORD" | chpasswd
17 changes: 17 additions & 0 deletions os/motd
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ +
+ +
+ ██████ ██████ ███ ███ ██ ██ ███ ██ █████ +
+ ██ ██ ██ ████ ████ ██ ██ ████ ██ ██ ██ +
+ ██ ███ ██ ██ ██ ████ ██ ██ ██ █████ ██ ██ ██ ███████ +
+ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +
+ ██████ ██████ ██ ██ ██████ ██ ████ ██ ██ +
+ +
+ ==================================================================== +
+ +
+ Welcome to GDMU-NA Cloud Development Platform ! +
+ +
+ +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

0 comments on commit e39db2d

Please sign in to comment.