commit f06e814dabf5386483e4b7bfecbe88da14c265db Author: stubbfel Date: Sun Nov 26 23:12:06 2023 +0100 init diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..f0917c1 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,17 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu +{ + "name": "Ubuntu", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/base:jammy", + "features": { + "ghcr.io/devcontainers/features/docker-in-docker:2": {}, + "ghcr.io/devcontainers-contrib/features/doctoolchain-sdkman:2": {} + }, + "remoteUser": "vscode", + "workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,Z", + "workspaceFolder": "/workspace", + + "runArgs": ["--userns=keep-id"], + "containerUser": "vscode" +} diff --git a/.docker-files/0-origin.Dockerfile b/.docker-files/0-origin.Dockerfile new file mode 100644 index 0000000..6a2f14d --- /dev/null +++ b/.docker-files/0-origin.Dockerfile @@ -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"] diff --git a/.docker-files/1-reordering.Dockerfile b/.docker-files/1-reordering.Dockerfile new file mode 100644 index 0000000..58a9146 --- /dev/null +++ b/.docker-files/1-reordering.Dockerfile @@ -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 diff --git a/.docker-files/2-grouping.Dockerfile b/.docker-files/2-grouping.Dockerfile new file mode 100644 index 0000000..7265f71 --- /dev/null +++ b/.docker-files/2-grouping.Dockerfile @@ -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 diff --git a/.docker-files/3-mounting.Dockerfile b/.docker-files/3-mounting.Dockerfile new file mode 100644 index 0000000..dd23f24 --- /dev/null +++ b/.docker-files/3-mounting.Dockerfile @@ -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 diff --git a/.docker-files/4-multi-stage.Dockerfile b/.docker-files/4-multi-stage.Dockerfile new file mode 100644 index 0000000..8de8523 --- /dev/null +++ b/.docker-files/4-multi-stage.Dockerfile @@ -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"] diff --git a/.docker-files/5-base-image.Dockerfile b/.docker-files/5-base-image.Dockerfile new file mode 100644 index 0000000..a3cdbbc --- /dev/null +++ b/.docker-files/5-base-image.Dockerfile @@ -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"] diff --git a/.docker-files/6-pinimage.Dockerfile b/.docker-files/6-pinimage.Dockerfile new file mode 100644 index 0000000..393a0c8 --- /dev/null +++ b/.docker-files/6-pinimage.Dockerfile @@ -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"] diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..1866e77 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +.devcontainer +.git +.docker-files +.dockerignore \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..a2de632 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,12 @@ +# Specify the minimum version of CMake required +cmake_minimum_required(VERSION 3.10) + +# Set the project name and version +project(HelloWorldApp VERSION 1.0) + +# Add the executable +add_executable(HelloWorldApp src/HelloWorldApp.cpp) +target_link_libraries(HelloWorldApp -static) + +# install executable +install(TARGETS HelloWorldApp DESTINATION bin) diff --git a/alias.sh b/alias.sh new file mode 100644 index 0000000..cab8f76 --- /dev/null +++ b/alias.sh @@ -0,0 +1 @@ +alias dive="docker run -ti --rm -v /var/run/docker.sock:/var/run/docker.sock wagoodman/dive" diff --git a/src/HelloWorldApp.cpp b/src/HelloWorldApp.cpp new file mode 100644 index 0000000..bc8f460 --- /dev/null +++ b/src/HelloWorldApp.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + std::cout << "Hello, World!" << std::endl; + return 0; +}