Initial commit

master
Icedream 2017-08-31 09:53:47 +02:00
commit fbb6bdef5a
Signed by: icedream
GPG Key ID: 1573F6D8EFE4D0CF
4 changed files with 100 additions and 0 deletions

19
Dockerfile Normal file
View File

@ -0,0 +1,19 @@
FROM debian
COPY hello.c /src/
RUN \
export DEBIAN_FRONTEND=noninteractive \
&& apt update \
&& apt install -y gcc \
&& ( \
cd /src \
&& gcc -Wall -o /usr/local/bin/hello hello.c \
) \
&& apt autoremove -y --purge gcc \
&& rm -rf \
/var/lib/apt/lists/* \
/var/tmp/* \
/tmp/*
CMD ["hello"]

19
alpine/Dockerfile Normal file
View File

@ -0,0 +1,19 @@
FROM alpine
COPY hello.c /src/
RUN \
export DEBIAN_FRONTEND=noninteractive \
&& apk add --no-cache --virtual .build-deps \
gcc \
musl-dev \
&& ( \
cd /src \
&& gcc -Wall -o /usr/local/bin/hello hello.c \
) \
&& apk del --no-cache .build-deps \
&& rm -rf \
/var/tmp/* \
/tmp/*
CMD ["hello"]

31
alpine/hello.c Normal file
View File

@ -0,0 +1,31 @@
#define _GNU_SOURCE
#include <stdlib.h>
#include <unistd.h>
#include <pwd.h>
#include <stdio.h>
#include <errno.h>
extern char *program_invocation_name;
extern char *program_invocation_short_name;
int main() {
register struct passwd *pw;
register uid_t uid;
printf("This is %s speaking.\n", program_invocation_name);
uid = geteuid();
pw = getpwuid(uid);
if (pw)
{
printf("Hello, %s!\n", pw->pw_name);
}
else
{
printf("I don't know your name but your ID is %d!\n", (unsigned) uid);
}
return 0;
}

31
hello.c Normal file
View File

@ -0,0 +1,31 @@
#define _GNU_SOURCE
#include <stdlib.h>
#include <unistd.h>
#include <pwd.h>
#include <stdio.h>
#include <errno.h>
extern char *program_invocation_name;
extern char *program_invocation_short_name;
int main() {
register struct passwd *pw;
register uid_t uid;
printf("This is %s speaking.\n", program_invocation_name);
uid = geteuid();
pw = getpwuid(uid);
if (pw)
{
printf("Hello, %s!\n", pw->pw_name);
}
else
{
printf("I don't know your name but your ID is %d!\n", (unsigned) uid);
}
return 0;
}