16 lines
543 B
Docker
16 lines
543 B
Docker
# use alpine as base image
|
|
FROM alpine AS build-env
|
|
# install build-base meta package inside build-env container
|
|
RUN apk add --no-cache build-base
|
|
# change directory to /app
|
|
WORKDIR /app
|
|
# copy all files from current directory inside the build-env container
|
|
COPY . .
|
|
# Compile the source code and generate hello binary executable file
|
|
RUN gcc -o hello helloDocker.c
|
|
# Set the executable file name as an environment variable
|
|
ENV PROGRAM_NAME=hello
|
|
# run the program using the environment variable
|
|
ENTRYPOINT ["sh", "-c", "/app/$PROGRAM_NAME"]
|
|
|