Skip to content

Commit

Permalink
Modified dockerfiles to reduce package installation duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
dmccoystephenson committed Jan 31, 2024
1 parent 132dd13 commit d834238
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 57 deletions.
32 changes: 18 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
# === BUILDER IMAGE ===
FROM alpine:3.12 as builder
# === RUNTIME DEPENDENCIES IMAGE ===
FROM alpine:3.12 as runtime-deps
USER root

WORKDIR /cvdi-stream

ENV DEBIAN_FRONTEND=noninteractive

# update the package manager
RUN apk update

# add runtime dependencies
RUN apk add --upgrade --no-cache \
bash \
librdkafka \
librdkafka-dev

# === BUILDER IMAGE ===
FROM runtime-deps as builder
USER root

WORKDIR /cvdi-stream

ENV DEBIAN_FRONTEND=noninteractive

# add build dependencies
RUN apk add --upgrade --no-cache --virtual .build-deps \
cmake \
g++ \
make \
librdkafka \
librdkafka-dev
make

# add the source and build files
ADD CMakeLists.txt /cvdi-stream
Expand All @@ -30,17 +40,11 @@ ADD ./config /cvdi-stream/config
RUN export LD_LIBRARY_PATH=/usr/local/lib && mkdir /cvdi-stream-build && cd /cvdi-stream-build && cmake /cvdi-stream && make

# === RUNTIME IMAGE ===
FROM alpine:3.12
FROM runtime-deps
USER root

WORKDIR /cvdi-stream

# add runtime dependencies
RUN apk add --upgrade --no-cache \
bash \
librdkafka \
librdkafka-dev

# copy the built files from the builder
COPY --from=builder /cvdi-stream-build/ /cvdi-stream-build/
COPY --from=builder /cvdi-stream /cvdi-stream
Expand Down
32 changes: 18 additions & 14 deletions Dockerfile-nsv
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# === RUNTIME DEPENDENCIES IMAGE ===
FROM alpine:3.12 as runtime-deps
USER root

WORKDIR /cvdi-stream

# update the package manager
RUN apk update

# add runtime dependencies
RUN apk add --upgrade --no-cache \
bash \
librdkafka \
librdkafka-dev

# === BUILDER IMAGE ===
FROM alpine:3.12 as builder
FROM runtime-deps as builder
USER root
ARG PPM_CONFIG_FILE
ARG PPM_MAP_FILE
Expand All @@ -8,16 +23,11 @@ WORKDIR /cvdi-stream

ENV DEBIAN_FRONTEND=noninteractive

# update the package manager
RUN apk update

# add build dependencies
RUN apk add --upgrade --no-cache --virtual .build-deps \
cmake \
g++ \
make \
librdkafka \
librdkafka-dev
make

# add the source and build files
ADD CMakeLists.txt /cvdi-stream
Expand All @@ -34,17 +44,11 @@ ADD ./config /cvdi-stream/config
RUN export LD_LIBRARY_PATH=/usr/local/lib && mkdir /cvdi-stream-build && cd /cvdi-stream-build && cmake /cvdi-stream && make

# === RUNTIME IMAGE ===
FROM alpine:3.12
FROM runtime-deps
USER root

WORKDIR /cvdi-stream

# add runtime dependencies
RUN apk add --upgrade --no-cache \
bash \
librdkafka \
librdkafka-dev

# copy the built files from the builder
COPY --from=builder /cvdi-stream-build/ /cvdi-stream-build/
COPY --from=builder /cvdi-stream /cvdi-stream
Expand Down
32 changes: 18 additions & 14 deletions Dockerfile.standalone
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
# === BUILDER IMAGE ===
FROM alpine:3.12 as builder
# === RUNTIME DEPENDENCIES IMAGE ===
FROM alpine:3.12 as runtime-deps
USER root

WORKDIR /cvdi-stream

ENV DEBIAN_FRONTEND=noninteractive

# update the package manager
RUN apk update

# add runtime dependencies
RUN apk add --upgrade --no-cache \
bash \
librdkafka \
librdkafka-dev

# === BUILDER IMAGE ===
FROM runtime-deps as builder
USER root

WORKDIR /cvdi-stream

ENV DEBIAN_FRONTEND=noninteractive

# add build dependencies
RUN apk add --upgrade --no-cache --virtual .build-deps \
cmake \
g++ \
make \
librdkafka \
librdkafka-dev
make

# add the source and build files
ADD CMakeLists.txt /cvdi-stream
Expand All @@ -30,17 +40,11 @@ ADD ./config /cvdi-stream/config
RUN export LD_LIBRARY_PATH=/usr/local/lib && mkdir /cvdi-stream-build && cd /cvdi-stream-build && cmake /cvdi-stream && make

# === RUNTIME IMAGE ===
FROM alpine:3.12
FROM runtime-deps
USER root

WORKDIR /cvdi-stream

# add runtime dependencies
RUN apk add --upgrade --no-cache \
bash \
librdkafka \
librdkafka-dev

# copy the built files from the builder
COPY --from=builder /cvdi-stream-build/ /cvdi-stream-build/
COPY --from=builder /cvdi-stream /cvdi-stream
Expand Down
33 changes: 18 additions & 15 deletions Dockerfile.testing
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
# === BUILDER IMAGE ===
FROM alpine:3.12 as builder
# === RUNTIME DEPENDENCIES IMAGE ===
FROM alpine:3.12 as runtime-deps
USER root

WORKDIR /cvdi-stream

ENV DEBIAN_FRONTEND=noninteractive

# update the package manager
RUN apk update

# add runtime dependencies
RUN apk add --upgrade --no-cache \
bash \
librdkafka \
librdkafka-dev

# === BUILDER IMAGE ===
FROM runtime-deps as builder
USER root

WORKDIR /cvdi-stream

ENV DEBIAN_FRONTEND=noninteractive

# add build dependencies
RUN apk add --upgrade --no-cache --virtual .build-deps \
cmake \
g++ \
make \
librdkafka \
librdkafka-dev
make

# add the source and build files
ADD CMakeLists.txt /cvdi-stream
Expand All @@ -30,18 +40,11 @@ ADD ./config /cvdi-stream/config
RUN export LD_LIBRARY_PATH=/usr/local/lib && mkdir /cvdi-stream-build && cd /cvdi-stream-build && cmake /cvdi-stream && make

# === RUNTIME IMAGE ===
FROM alpine:3.12
FROM runtime-deps
USER root

WORKDIR /cvdi-stream

# add runtime dependencies
RUN apk add --upgrade --no-cache \
bash \
python3 \
librdkafka \
librdkafka-dev

# copy the built files from the builder
COPY --from=builder /cvdi-stream-build/ /cvdi-stream-build/
COPY --from=builder /cvdi-stream /cvdi-stream
Expand Down

0 comments on commit d834238

Please sign in to comment.