Skip to content

Commit

Permalink
feat: Update Dockerfile to be based on Alpine
Browse files Browse the repository at this point in the history
  • Loading branch information
DownerCase committed Jan 13, 2025
1 parent 2fb3656 commit ea98272
Showing 1 changed file with 39 additions and 49 deletions.
88 changes: 39 additions & 49 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,56 +1,54 @@
ARG BASE_IMAGE=docker.io/ubuntu:oracular-20241120
ARG BASE_IMAGE=docker.io/alpine:3.21.2

###
# Build eCAL 6 from source
###
FROM ${BASE_IMAGE} AS builder

RUN apt-get update && apt-get install --no-install-recommends -y\
ca-certificates \
RUN apk add --no-cache \
asio-dev \
cmake \
g++ \
git \
libasio-dev \
libprotobuf-dev \
libprotoc-dev \
libtclap-dev \
libyaml-cpp-dev \
ninja-build \
protobuf-compiler \
&& rm -rf /var/lib/apt/lists/*
ninja-is-really-ninja \
protobuf-dev \
tclap-dev \
yaml-cpp-dev \
# fts functions which are missing musl libc
musl-fts-dev

# filter=tree:0 will fetch the commits but their trees will be fetched on-demand
# So we end up with the full commit history but only download trees for HEAD
# This is needed over shallow clone for the tag-based auto-versioning
# Reset added to ensure the same commit is always used, even if master advances
RUN git clone --single-branch --filter=tree:0 --branch master https://github.com/eclipse-ecal/ecal.git /ecal \
&& git -C ./ecal reset --hard 00f8ef0a2af296911e7de661e9c5f61a68abf809
WORKDIR /ecal

# Only download the submodules for dependencies not available as system packages
RUN git submodule update --init --single-branch --depth 1 \
RUN git clone --single-branch --filter=tree:0 --branch alpine https://github.com/DownerCase/ecal.git /ecal \
&& git -C /ecal reset --hard c9e9a489e44420899693bba7360ce1e235d691e6 \
# Only download the submodules for dependencies not available as system packages
&& git -C /ecal submodule update --init --single-branch --depth 1 \
thirdparty/recycle/recycle \
thirdparty/tcp_pubsub/tcp_pubsub \
thirdparty/ecaludp/ecaludp

WORKDIR /ecal

# TODO: Blocker for installing to / or / usr
# - Fix usage of `INSTALL_INCLUDE_DIR` instead of `eCAL_install_include_dir`
# - Get CMakeFunctions to use GNUInstallDirs

# Configure a minimal build with less vendored dependencies
RUN cmake --preset core -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_STAGING_PREFIX=staging \
-DBUILD_TIME=OFF \
-DECAL_THIRDPARTY_BUILD_ASIO=OFF \
-DECAL_THIRDPARTY_BUILD_PROTOBUF=OFF \
-DECAL_THIRDPARTY_BUILD_YAML-CPP=OFF \
-DECAL_THIRDPARTY_BUILD_TCLAP=OFF

RUN cmake --build --preset core

# Component based install avoids the unneeded `app` component
RUN cmake --install ./out/core/build --strip --component configuration \
RUN \
# Configure a minimal build with less vendored dependencies
cmake --preset core -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_STAGING_PREFIX=staging \
-DBUILD_TIME=OFF \
-DECAL_THIRDPARTY_BUILD_ASIO=OFF \
-DECAL_THIRDPARTY_BUILD_PROTOBUF=OFF \
-DECAL_THIRDPARTY_BUILD_YAML-CPP=OFF \
-DECAL_THIRDPARTY_BUILD_TCLAP=OFF \
# Build core preset
&& cmake --build --preset core \
# Component based install avoids the unneeded `app` component
&& cmake --install ./out/core/build --strip --component configuration \
&& cmake --install ./out/core/build --strip --component sdk \
&& cmake --install ./out/core/build --strip --component Unspecified

Expand All @@ -61,36 +59,28 @@ FROM ${BASE_IMAGE} AS dev-base

LABEL org.opencontainers.image.source https://github.com/downercase/ecal-go

RUN apt-get update && apt-get install --no-install-recommends -y\
g++ \
libyaml-cpp0.8 \
&& rm -rf /var/lib/apt/lists/*

# copy the ca-certificate.crt from the build stage
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

COPY --from=builder /ecal/staging /usr/local

# Update dynamic linker so it knows about our new libraries
RUN ldconfig

###
# Dev build-stage, for consuming eCAL and building/testing the C interface library
###
FROM dev-base AS dev-cpp

RUN apt-get update && apt-get install --no-install-recommends -y\
RUN apk add --no-cache \
cmake \
libprotobuf-dev \
ninja-build \
&& rm -rf /var/lib/apt/lists/*
g++ \
protobuf-dev \
# Ninja build compatible
samurai

###
# Dev build-stage, for consuming eCAL and building/testing the Go code
###
FROM dev-base AS dev-go

RUN apt-get update && apt-get install --no-install-recommends -y\
golang \
&& rm -rf /var/lib/apt/lists/*
RUN apk add --no-cache \
g++ \
go \
musl-fts \
yaml-cpp

0 comments on commit ea98272

Please sign in to comment.