Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions Dockerfile.build
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# explicitly use Debian for maximum cross-architecture compatibility
FROM debian:jessie

RUN apt-get update && apt-get install -y make nasm && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
libc6-dev \
make \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /usr/src/hello
COPY . .

RUN make clean all test
RUN set -x \
&& make clean all test \
&& ls -l */hello

CMD ["./hello-world/hello"]
3 changes: 0 additions & 3 deletions Dockerfile.template

This file was deleted.

21 changes: 9 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
IMAGES := \
hello-world \
hola-mundo \
hello-seattle
C_TARGETS := $(addsuffix hello, $(wildcard */))

ASM_TARGETS := $(addsuffix /hello, $(IMAGES))
CC := gcc
CFLAGS := -static -Os -nostartfiles -fno-asynchronous-unwind-tables

.PHONY: all
all: $(ASM_TARGETS)
all: $(C_TARGETS)

$(ASM_TARGETS): hello.asm
mkdir -p '$(dir $@)'
nasm -o '$@' -DDOCKER_IMAGE="'$$(dirname '$@')'" '$<'
chmod +x '$@'
$(C_TARGETS): hello.c
$(CC) $(CFLAGS) -o '$@' -D DOCKER_IMAGE='"$(@D)"' -D DOCKER_GREETING="\"$$(cat '$(@D)/greeting.txt')\"" '$<'
strip -R .comment -s '$@'

.PHONY: clean
clean:
-rm -vrf $(addsuffix /, $(IMAGES))
-rm -vrf $(C_TARGETS)

.PHONY: test
test: $(ASM_TARGETS)
test: $(C_TARGETS)
@for b in $^; do \
( set -x && "./$$b" ); \
( set -x && "./$$b" | grep -q '"'"$$(dirname "$$b")"'"' ); \
Expand Down
1 change: 1 addition & 0 deletions hello-seattle/greeting.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello from DockerCon 2016 (Seattle)!
Binary file modified hello-seattle/hello
Binary file not shown.
1 change: 1 addition & 0 deletions hello-world/greeting.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello from Docker!
Binary file modified hello-world/hello
Binary file not shown.
93 changes: 0 additions & 93 deletions hello.asm

This file was deleted.

41 changes: 41 additions & 0 deletions hello.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//#include <unistd.h>
#include <sys/syscall.h>

#ifndef DOCKER_IMAGE
#define DOCKER_IMAGE "hello-world"
#endif

#ifndef DOCKER_GREETING
#define DOCKER_GREETING "Hello from Docker!"
#endif

const char message[] =
"\n"
DOCKER_GREETING "\n"
"This message shows that your installation appears to be working correctly.\n"
"\n"
"To generate this message, Docker took the following steps:\n"
" 1. The Docker client contacted the Docker daemon.\n"
" 2. The Docker daemon pulled the \"" DOCKER_IMAGE "\" image from the Docker Hub.\n"
" 3. The Docker daemon created a new container from that image which runs the\n"
" executable that produces the output you are currently reading.\n"
" 4. The Docker daemon streamed that output to the Docker client, which sent it\n"
" to your terminal.\n"
"\n"
"To try something more ambitious, you can run an Ubuntu container with:\n"
" $ docker run -it ubuntu bash\n"
"\n"
"Share images, automate workflows, and more with a free Docker Hub account:\n"
" https://hub.docker.com\n"
"\n"
"For more examples and ideas, visit:\n"
" https://docs.docker.com/engine/userguide/\n"
"\n";

void _start() {
//write(1, message, sizeof(message) - 1);
syscall(SYS_write, 1, message, sizeof(message) - 1);

//_exit(0);
syscall(SYS_exit, 0);
}
1 change: 1 addition & 0 deletions hola-mundo/greeting.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
¡Hola de DockerCon EU 2015 (Barcelona)!
Binary file modified hola-mundo/hello
Binary file not shown.
14 changes: 8 additions & 6 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ set -e
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"

set -x

docker build -f Dockerfile.build -t hello-world:build .
rm -rf */
docker run --rm hello-world:build sh -c 'tar -c */' | tar -x
for d in */; do
d="${d%/}"
cp -v Dockerfile.template "$d/Dockerfile"
"./$d/hello" > /dev/null

rm -rf */hello
docker run --rm hello-world:build sh -c 'tar --create */hello' | tar --extract --wildcards '*/hello'

for h in */hello; do
d="$(dirname "$h")"
"$h" > /dev/null
docker build -t hello-world:"test-$d" "$d"
docker run --rm hello-world:"test-$d"
done