Skip to content

Commit

Permalink
Merge with emdocker
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekseyZhmulin committed Apr 22, 2024
1 parent 5abf327 commit eec3164
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 20 deletions.
78 changes: 58 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

FROM embox/emdocker as build
FROM ubuntu:16.04

## Update the repository and install utils
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get -y --no-install-recommends install \
nfs-kernel-server \
Expand All @@ -21,13 +22,66 @@ RUN apt-get update && \
xvnc4viewer \
ffmpeg \
git \
sudo \
iptables \
openssh-server \
iproute2 \
bzip2 \
unzip \
xz-utils \
python \
curl \
make \
patch \
cpio \
gcc-multilib \
g++-multilib \
gdb \
qemu-system \
ruby \
bison \
flex \
bc \
autoconf \
pkg-config \
mtd-utils \
ntfs-3g \
autotools-dev \
automake \
xutils-dev \
libtool \
dosfstools && \
apt-get clean && \
rm -rf /var/lib/apt /var/cache/apt

## risc-v crosscompiler
RUN curl -k -L -s "https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-8.2.0-2019.05.3-x86_64-linux-ubuntu14.tar.gz" | \
tar -xzC /opt
## Install crosscompilers
RUN for a in aarch64-elf arm-none-eabi microblaze-elf mips-mti-elf powerpc-elf riscv64-unknown-elf sparc-elf; do \
curl -k -L "https://github.com/embox/crosstool/releases/download/2.42-13.2.0-14.2/$a-toolchain.tar.bz2" | \
tar -jxC /opt; \
done

## Set environment variables
ENV PATH=$PATH:\
/opt/aarch64-elf-toolchain/bin:\
/opt/arm-none-eabi-toolchain/bin:\
/opt/microblaze-elf-toolchain/bin:\
/opt/mips-mti-elf-toolchain/bin:\
/opt/powerpc-elf-toolchain/bin:\
/opt/riscv64-unknown-elf-toolchain/bin:\
/opt/sparc-elf-toolchain/bin

COPY create_matching_user.sh /usr/local/sbin/
COPY docker_start.sh /usr/local/sbin/

COPY id_rsa.pub /home/user/.ssh/authorized_keys
COPY user.bashrc /home/user/.bashrc
COPY user.bash_profile /home/user/.bash_profile
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

## x86/test/fs
RUN for i in $(seq 0 9); do \
mknod /dev/loop$i -m0660 b 7 $i; \
done

# x86/test/fs nfs
RUN mkdir -p -m 777 /var/nfs_test
Expand All @@ -44,20 +98,6 @@ COPY ntp.conf /etc/
RUN useradd -u 65534 -o -ms /bin/bash rlogin_user
RUN /bin/echo -e "rlogin\nrlogin" | passwd rlogin_user

FROM scratch
MAINTAINER Anton Kozlov <drakon.mega@gmail.com>

COPY --from=build / /

ENV PATH=$PATH:\
/opt/gcc-arm-none-eabi-6-2017-q2-update/bin:\
/opt/gcc-arm-8.3-2019.03-x86_64-aarch64-elf/bin:\
/opt/riscv64-unknown-elf-gcc-8.2.0-2019.05.3-x86_64-linux-ubuntu14/bin:\
/opt/microblaze-elf-toolchain/bin:\
/opt/mips-elf-toolchain/bin:\
/opt/powerpc-elf-toolchain/bin:\
/opt/sparc-elf-toolchain/bin

CMD mount -t tmpfs none /var/nfs_test && \
service rpcbind restart && \
/etc/init.d/nfs-kernel-server restart && \
Expand All @@ -66,5 +106,3 @@ CMD mount -t tmpfs none /var/nfs_test && \
/etc/init.d/ntp restart && \
inetd && \
/usr/local/sbin/docker_start.sh


15 changes: 15 additions & 0 deletions create_matching_user.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
user=$1
target_dir=$2
home=/home/$user
uid=$(stat -c %u $target_dir)
gid=$(stat -c %g $target_dir)

mkdir -p $home
chown -R $uid:$gid $home

if ! getent group $gid; then
groupadd -g $gid embox_user
fi

useradd -u $uid -g $gid -G sudo -d $home -s /bin/bash $user
6 changes: 6 additions & 0 deletions docker_start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

/usr/local/sbin/create_matching_user.sh user /embox

mkdir -p /var/run/sshd
exec /usr/sbin/sshd -D
27 changes: 27 additions & 0 deletions id_rsa
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEAmsnvOMna7yBhs83JRMXa6PQFh4o/zDAe9p6yYOo2DOtl6Tv9
CTjyamOXmEwesm6SaXjPIBQxUozKofcH17rDls1K6OwCaNpl0ym4rxaT/q1hAZu0
/2VninFgMw/us/paB/LeWdJ5lcdxXMKLgor4R3uI9HRcowMvHZ5R4x2tVUoc9bjR
kB++GmPRt/AWEj6+R7UnycT5/Z77fNdjfw0ahDxnZAoKSqtbvIFOGwdSDH9/E7DP
g3G4Vf1E5udGkpALahp1HeWaPJHMG/lOlVSLZahK5A92KhWI3oLx1NLzLKCDYsSt
RO+DAiqQ9wUe4YzSsDlgewPveML5fLsJDPz2EwIDAQABAoIBACCUVDedtOkT5byU
mcJR6quRgQBwRtFRZ5L9AAqKAWpiuYaHy9B/Hfbqk2PI0cU4pLRyaxYTafY4EAZb
Gll7w+Mfvp6b3j33iesSIv8nP2shTwOppEUFMO/gwSC+P729+ekmY0qAlHrECcY+
ZGLLoUpaZA8f1sewyd/wDMhC3NLQfM9bQ77Ec0zi6Y2kQC15w2xE04uS47+Cb74i
JMkp/87oeWOH/Rr8J/cIlkeujSmDxU/v12KWGm7QF8ofhpDM32KM6oagdd728XDP
RWi/30+aenqg3kXV7CKRqmJfzPr6cU9eZxESllIVQTgteskqTiAKow7+78vzJ+Yg
GMDOZwECgYEAyGepk9QehsLai48n76THHAJWOeFi4+ze/2gJaWND49d8Vb7CDrfk
52Phlfq2/0QdnOXqQsd1elmxE8jnT524pGF+A/7nTcNjTVf8fOZPDBlkzpIbm2I7
R9rhJAFUInLNAmSchwDM/33bDKjVNwaK79efNkjT58DnhoHiemdaz8ECgYEAxbq1
6nEii+h5+TRKu664nC7feJJWJZw8AihxIPvGq+mUrEcDma0a9B610SN0DUwh6iCd
Ux6ww16AQbRpvKz+AFcI9CeWGbUJhL8AJ9VNlBfuhZ24vybxtntzia1ySBTi5v7U
jXZ5AkxO3JTiFt8bb6nuZr3cdrhu9Q2gpE6SOtMCgYEArXx/4sd4fbTlOHd/XQfK
jka/mm+xChsemP/ZVfBm7zC2JAx1NgSgFmfy+8EE9kpjUFYAzDqbSoWms7fx9oxV
MYhsbM0YM8t3hZcrrnw55gF9sQ3u9D6/jt6+lErKKOA09WNf1cctr+el33mwymfR
kvuYiofVWgU26Mw74Tbj+IECgYEAk6rNETlMw4/rB+G1rlTeKkYXPsSK8ausZTAu
zKM7zEe1cLPYTHyrFIWa44XGteeVrHSPCfRxrnZ08pz6Gp5XU4msdiraPnilky3R
v+3c8iytRbx0rM041z97Gece4hY3HqxRsRQ5ay3x92p5LvuQUeRm1vQUIdW7h+eV
gR/stWECgYEApyUJXnqGQ5GGd8vjCLct38cKekmgPyTaXDbMDIhXBikAcvBzEVZQ
qPdxhsFrDhUR62WiaDUW4LscOtoUpTqpjgMe6oWvXmT6fbhokn60cfz3snfxuNdn
hVaSNxmzBS/xKeW6TUtYtJsFzznvbvl3JgzBJjw3COQeDY+NEkxTkv0=
-----END RSA PRIVATE KEY-----
1 change: 1 addition & 0 deletions id_rsa.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCaye84ydrvIGGzzclExdro9AWHij/MMB72nrJg6jYM62XpO/0JOPJqY5eYTB6ybpJpeM8gFDFSjMqh9wfXusOWzUro7AJo2mXTKbivFpP+rWEBm7T/ZWeKcWAzD+6z+loH8t5Z0nmVx3FcwouCivhHe4j0dFyjAy8dnlHjHa1VShz1uNGQH74aY9G38BYSPr5HtSfJxPn9nvt812N/DRqEPGdkCgpKq1u8gU4bB1IMf38TsM+DcbhV/UTm50aSkAtqGnUd5Zo8kcwb+U6VVItlqErkD3YqFYjegvHU0vMsoINixK1E74MCKpD3BR7hjNKwOWB7A+94wvl8uwkM/PYT anton@twister
1 change: 1 addition & 0 deletions user.bash_profile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
. ~/.bashrc
4 changes: 4 additions & 0 deletions user.bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export EMBOX_DIR=/embox
export AUTOQEMU_KVM_ARG=""

cd $EMBOX_DIR

0 comments on commit eec3164

Please sign in to comment.