init
This commit is contained in:
29
.docker-files/0-origin.Dockerfile
Normal file
29
.docker-files/0-origin.Dockerfile
Normal file
@@ -0,0 +1,29 @@
|
||||
# Use Ubuntu 22.04 as the base image
|
||||
FROM ubuntu
|
||||
|
||||
# Copy all source files from the current directory to /app in the image
|
||||
COPY . .
|
||||
|
||||
# Update package list to ensure we have the latest information
|
||||
RUN apt-get update
|
||||
|
||||
# Install g++
|
||||
RUN apt-get install -y g++
|
||||
|
||||
# Install cmake to manage the build process
|
||||
RUN apt-get install -y cmake
|
||||
|
||||
# Configuring and building the app using cmake
|
||||
RUN cmake .
|
||||
|
||||
# Building the app using make
|
||||
RUN make
|
||||
|
||||
# Building the app again (if needed)
|
||||
RUN make install
|
||||
|
||||
# Clean up package lists to reduce the image size
|
||||
RUN rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Setting entry point to the app binary
|
||||
ENTRYPOINT ["/usr/local/bin/HelloWorldApp"]
|
||||
28
.docker-files/1-reordering.Dockerfile
Normal file
28
.docker-files/1-reordering.Dockerfile
Normal file
@@ -0,0 +1,28 @@
|
||||
FROM ubuntu
|
||||
|
||||
# Setting entry point to the app binary
|
||||
ENTRYPOINT ["/usr/local/bin/HelloWorldApp"]
|
||||
|
||||
# Update package list to ensure we have the latest information
|
||||
RUN apt-get update
|
||||
|
||||
# Install g++
|
||||
RUN apt-get install -y g++
|
||||
|
||||
# Install cmake to manage the build process
|
||||
RUN apt-get install -y cmake
|
||||
|
||||
# Clean up package lists to reduce the image size
|
||||
RUN rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy all source files from the current directory to /app in the image
|
||||
COPY . .
|
||||
|
||||
# Configuring and building the app using cmake
|
||||
RUN cmake .
|
||||
|
||||
# Building the app using make
|
||||
RUN make
|
||||
|
||||
# Install the app
|
||||
RUN make install
|
||||
18
.docker-files/2-grouping.Dockerfile
Normal file
18
.docker-files/2-grouping.Dockerfile
Normal file
@@ -0,0 +1,18 @@
|
||||
FROM ubuntu
|
||||
|
||||
# Setting entry point to the app binary
|
||||
ENTRYPOINT ["/usr/local/bin/HelloWorldApp"]
|
||||
|
||||
# Install cmake to manage the build process
|
||||
RUN apt-get update \
|
||||
&& apt-get install --no-install-recommends -y g++ make cmake \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy all source files from the current directory to /app in the image
|
||||
COPY CMakeLists.txt .
|
||||
COPY src ./src
|
||||
|
||||
# Configuring, building and install the app
|
||||
RUN cmake . \
|
||||
&& make \
|
||||
&& make install
|
||||
20
.docker-files/3-mounting.Dockerfile
Normal file
20
.docker-files/3-mounting.Dockerfile
Normal file
@@ -0,0 +1,20 @@
|
||||
FROM ubuntu
|
||||
|
||||
# Setting entry point to the app binary
|
||||
ENTRYPOINT ["/usr/local/bin/HelloWorldApp"]
|
||||
|
||||
# Install cmake to manage the build process. Removing cache by `docker builder prune`
|
||||
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked --mount=type=cache,target=/var/lib/apt,sharing=locked \
|
||||
rm -f /etc/apt/apt.conf.d/docker-clean \
|
||||
&& echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y --no-install-recommends g++ make cmake
|
||||
|
||||
# Copy all source files from the current directory to /app in the image
|
||||
COPY CMakeLists.txt .
|
||||
COPY src ./src
|
||||
|
||||
# Configuring, building and install the app
|
||||
RUN cmake . \
|
||||
&& make \
|
||||
&& make install
|
||||
27
.docker-files/4-multi-stage.Dockerfile
Normal file
27
.docker-files/4-multi-stage.Dockerfile
Normal file
@@ -0,0 +1,27 @@
|
||||
# === Builder Stage ===
|
||||
FROM ubuntu as builder
|
||||
|
||||
# Install cmake to manage the build process. Removing cache by `docker builder prune`
|
||||
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked --mount=type=cache,target=/var/lib/apt,sharing=locked \
|
||||
rm -f /etc/apt/apt.conf.d/docker-clean \
|
||||
&& echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y --no-install-recommends g++ make cmake
|
||||
|
||||
# Copy all source files from the current directory to /app in the image
|
||||
COPY CMakeLists.txt .
|
||||
COPY src ./src
|
||||
|
||||
# Configuring, building and install the app
|
||||
RUN cmake . \
|
||||
&& make \
|
||||
&& make install
|
||||
|
||||
# === Production Stage ===
|
||||
FROM ubuntu
|
||||
|
||||
# Copy only the built artifacts from the builder stage
|
||||
COPY --from=builder /usr/local/bin/HelloWorldApp /HelloWorldApp
|
||||
|
||||
# Setting entry point to the app binary
|
||||
ENTRYPOINT ["/HelloWorldApp"]
|
||||
29
.docker-files/5-base-image.Dockerfile
Normal file
29
.docker-files/5-base-image.Dockerfile
Normal file
@@ -0,0 +1,29 @@
|
||||
# === Builder Stage ===
|
||||
FROM alpine as builder
|
||||
|
||||
# Install cmake to manage the build process. Removing cache by `docker builder prune`
|
||||
RUN --mount=type=cache,target=/var/cache/apk,sharing=locked \
|
||||
apk add --cache-dir /var/cache/apk g++ make cmake
|
||||
|
||||
# Alternatively, you can use --no-cache option to avoid creating a cache inside the container.
|
||||
# However, note that this will also prevent the use of the shared cache, affecting caching efficiency.
|
||||
# Example:
|
||||
# RUN apk --no-cache add g++ mahe cmake
|
||||
|
||||
# Copy all source files from the current directory to /app in the image
|
||||
COPY CMakeLists.txt .
|
||||
COPY src ./src
|
||||
|
||||
# Configuring, building and install the app
|
||||
RUN cmake . \
|
||||
&& make \
|
||||
&& make install
|
||||
|
||||
# === Production Stage ===
|
||||
FROM alpine
|
||||
|
||||
# Copy only the built artifacts from the builder stage
|
||||
COPY --from=builder /usr/local/bin/HelloWorldApp /HelloWorldApp
|
||||
|
||||
# Setting entry point to the app binary
|
||||
ENTRYPOINT ["/HelloWorldApp"]
|
||||
29
.docker-files/6-pinimage.Dockerfile
Normal file
29
.docker-files/6-pinimage.Dockerfile
Normal file
@@ -0,0 +1,29 @@
|
||||
# === Builder Stage ===
|
||||
FROM alpine:3.18.4@sha256:48d9183eb12a05c99bcc0bf44a003607b8e941e1d4f41f9ad12bdcc4b5672f86 as builder
|
||||
|
||||
# Install cmake to manage the build process. Removing cache by `docker builder prune`
|
||||
RUN --mount=type=cache,target=/var/cache/apk,sharing=locked \
|
||||
apk add --cache-dir /var/cache/apk g++ make cmake
|
||||
|
||||
# Alternatively, you can use --no-cache option to avoid creating a cache inside the container.
|
||||
# However, note that this will also prevent the use of the shared cache, affecting caching efficiency.
|
||||
# Example:
|
||||
# RUN apk --no-cache add g++ mahe cmake
|
||||
|
||||
# Copy all source files from the current directory to /app in the image
|
||||
COPY CMakeLists.txt .
|
||||
COPY src ./src
|
||||
|
||||
# Configuring, building and install the app
|
||||
RUN cmake . \
|
||||
&& make \
|
||||
&& make install
|
||||
|
||||
# === Production Stage ===
|
||||
FROM alpine:3.18.4@sha256:48d9183eb12a05c99bcc0bf44a003607b8e941e1d4f41f9ad12bdcc4b5672f86
|
||||
|
||||
# Copy only the built artifacts from the builder stage
|
||||
COPY --from=builder /usr/local/bin/HelloWorldApp /HelloWorldApp
|
||||
|
||||
# Setting entry point to the app binary
|
||||
ENTRYPOINT ["/HelloWorldApp"]
|
||||
Reference in New Issue
Block a user