From 0de8c248fe42f13481b86bdfb293384207dafe43 Mon Sep 17 00:00:00 2001 From: Hugo LAMY Date: Mon, 26 Sep 2022 14:57:21 +0200 Subject: [PATCH] added back test hello world --- srcs/docker-compose.yml | 7 ++++ srcs/requirements/test/.dockerignore | 0 srcs/requirements/test/Dockerfile | 47 +++++++++++++++++++++++++ srcs/requirements/test/tools/hello | Bin 0 -> 142 bytes srcs/requirements/test/tools/hello.asm | 16 +++++++++ 5 files changed, 70 insertions(+) create mode 100644 srcs/requirements/test/.dockerignore create mode 100644 srcs/requirements/test/Dockerfile create mode 100755 srcs/requirements/test/tools/hello create mode 100644 srcs/requirements/test/tools/hello.asm diff --git a/srcs/docker-compose.yml b/srcs/docker-compose.yml index ed69e5b..fc79b33 100644 --- a/srcs/docker-compose.yml +++ b/srcs/docker-compose.yml @@ -8,6 +8,13 @@ version: "3.8" services: +# --------------------------------- +# test: +# build: +# context: ./requirements/test +# dockerfile: Dockerfile +# image: test +# container_name: test_container # --------------------------------- nginx: #restart: on-failure diff --git a/srcs/requirements/test/.dockerignore b/srcs/requirements/test/.dockerignore new file mode 100644 index 0000000..e69de29 diff --git a/srcs/requirements/test/Dockerfile b/srcs/requirements/test/Dockerfile new file mode 100644 index 0000000..377158b --- /dev/null +++ b/srcs/requirements/test/Dockerfile @@ -0,0 +1,47 @@ + +# basic test +# build with : sudo docker build --tag test . +# run with : sudo docker run test +# 'hello' in assembly found here : http://timelessname.com/elfbin/ +FROM scratch +COPY tools/hello / +CMD [ "/hello" ] + +## working +#FROM scratch +#WORKDIR / +#COPY hello / +#CMD [ "/hello" ] + +## working, when WORKDIR is absent, it's default is set to "/" +#FROM scratch +#COPY hello / +#CMD [ "/hello" ] + +## not working, when CMD execute in shell form, instead of exec form [] +#FROM scratch +#COPY hello / +#CMD /hello + +## not working, because c executable need library +#FROM scratch +#COPY hello_c / +#CMD [ "/hello_c" ] + +## not working, when executable is copied to ".", because WORKDIR value is not "." but "/" since we gave it a relativ path so it was build in top of the implicit absolut path "/" +#FROM scratch +#WORKDIR . +#COPY hello . +#CMD [ "hello" ] + +## not working, when WORKDIR is set to the present directory and executable is not copied, because the workdir is not the present directory but a directory in the file system of docker : executable need to be copied there to function +#FROM scratch +#WORKDIR /home/simplonco/Desktop/42/14_inception/inception/srcs/requirements/mariadb +#CMD [ "hello" ] + +## working, because "hello" is copied to "/" and execute from "/" +#FROM scratch +#WORKDIR . +#COPY hello / +#CMD [ "/hello" ] + diff --git a/srcs/requirements/test/tools/hello b/srcs/requirements/test/tools/hello new file mode 100755 index 0000000000000000000000000000000000000000..2eeeb9d4d00cf94be2d2a62558028c8f3d74e841 GIT binary patch literal 142 zcmb<-^>JflWc0{X2+uFdN#SB*U}j)sU|?uyVBs(U(hNITfW+B`*AWT~Obi+ftPCt* zd5{zXPz?w#0y06E6(lCW0G3|@WGR=ftOdHrfPkYv~a I5;)rc051O*%K!iX literal 0 HcmV?d00001 diff --git a/srcs/requirements/test/tools/hello.asm b/srcs/requirements/test/tools/hello.asm new file mode 100644 index 0000000..0cc26b9 --- /dev/null +++ b/srcs/requirements/test/tools/hello.asm @@ -0,0 +1,16 @@ + SECTION .data +msg: db "Hi World",10 +len: equ $-msg + + SECTION .text + global main +main: + mov edx,len + mov ecx,msg + mov ebx,1 + mov eax,4 + int 0x80 + mov ebx,0 + mov eax,1 + int 0x80 +