Skip to content

Commit

Permalink
feat: Update Dockerfile to be based on Alpine and update eCAL (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
DownerCase authored Jan 13, 2025
1 parent 2fb3656 commit 5d57ea5
Show file tree
Hide file tree
Showing 30 changed files with 172 additions and 147 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

6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ jobs:
- uses: actions/checkout@v4

- name: Configure
run: cmake -S . -B build -G Ninja -Werror=dev -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_TOOLCHAIN_FILE=project/gcc.cmake
run: 'cmake -S . -B build -G Ninja -Werror=dev
-DCMAKE_COMPILE_WARNING_AS_ERROR=ON
-DCMAKE_TOOLCHAIN_FILE=project/gcc.cmake
-DCMAKE_CXX_FLAGS="-Wall -Wextra -Wpedantic -Wconversion"
'

- name: Build
run: cmake --build ./build
Expand Down
2 changes: 2 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ linters-settings:
- standard
- default
- localmodule
gomoddirectives:
replace-local: true
ireturn:
allow:
- tea.Model
Expand Down
2 changes: 1 addition & 1 deletion cmd/go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module cmd
module github.com/DownerCase/ecal-go/cmd

go 1.23.2

Expand Down
5 changes: 2 additions & 3 deletions cmd/monitor/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import (
"errors"
"fmt"

"github.com/DownerCase/ecal-go/ecal/monitoring"
"github.com/charmbracelet/bubbles/table"
tea "github.com/charmbracelet/bubbletea"

"github.com/DownerCase/ecal-go/ecal/monitoring"
)

var (
Expand Down Expand Up @@ -54,7 +53,7 @@ func getTopicMonitoring(topicType TopicType) []monitoring.TopicMon {
return nil
}

func getTopicFromID(topicType TopicType, id string) (monitoring.TopicMon, error) {
func getTopicFromID(topicType TopicType, id uint64) (monitoring.TopicMon, error) {
topicList := getTopicMonitoring(topicType)
for _, topic := range topicList {
if topic.TopicID == id {
Expand Down
3 changes: 1 addition & 2 deletions cmd/monitor/config_page.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package main

import (
"github.com/DownerCase/ecal-go/ecal"
"github.com/charmbracelet/bubbles/viewport"
tea "github.com/charmbracelet/bubbletea"

"github.com/DownerCase/ecal-go/ecal"
)

type ModelConfig struct {
Expand Down
3 changes: 1 addition & 2 deletions cmd/monitor/hosts_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ package main
import (
"strconv"

"github.com/DownerCase/ecal-go/ecal/monitoring"
"github.com/charmbracelet/bubbles/table"
tea "github.com/charmbracelet/bubbletea"

"github.com/DownerCase/ecal-go/ecal/monitoring"
)

type ModelHosts struct {
Expand Down
3 changes: 1 addition & 2 deletions cmd/monitor/log_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ package main
import (
"time"

"github.com/DownerCase/ecal-go/ecal/logging"
"github.com/charmbracelet/bubbles/help"
"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/table"
tea "github.com/charmbracelet/bubbletea"

"github.com/DownerCase/ecal-go/ecal/logging"
)

type LoggingPage int
Expand Down
3 changes: 1 addition & 2 deletions cmd/monitor/page_processes_detailed.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import (
"fmt"
"strconv"

"github.com/DownerCase/ecal-go/ecal/monitoring"
"github.com/charmbracelet/bubbles/table"
tea "github.com/charmbracelet/bubbletea"

"github.com/DownerCase/ecal-go/ecal/monitoring"
)

type ModelProcessDetailed struct {
Expand Down
3 changes: 1 addition & 2 deletions cmd/monitor/page_processes_main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import (
"path/filepath"
"strconv"

"github.com/DownerCase/ecal-go/ecal/monitoring"
"github.com/charmbracelet/bubbles/table"
tea "github.com/charmbracelet/bubbletea"

"github.com/DownerCase/ecal-go/ecal/monitoring"
)

type ModelProcessesMain struct {
Expand Down
9 changes: 4 additions & 5 deletions cmd/monitor/page_services_detailed.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ import (
"fmt"
"strconv"

"github.com/DownerCase/ecal-go/ecal/monitoring"
"github.com/charmbracelet/bubbles/table"
tea "github.com/charmbracelet/bubbletea"

"github.com/DownerCase/ecal-go/ecal/monitoring"
)

type ModelServiceDetailed struct {
table table.Model
ID string
ID uint64
IsServer bool
}

Expand All @@ -24,7 +23,7 @@ func NewDetailedServiceModel() *ModelServiceDetailed {

return &ModelServiceDetailed{
table: NewTable(cols),
ID: "",
ID: 0,
}
}

Expand Down Expand Up @@ -97,7 +96,7 @@ func getMethodRows(b monitoring.ServiceBase) []table.Row {
for _, method := range b.Methods {
rows = append(rows, table.Row{
method.Name,
fmt.Sprintf("%s -> %s (Called x%v)", method.RequestType.Type, method.ResponseType.Type, method.CallCount),
fmt.Sprintf("%v -> %v (Called x%v)", method.RequestType.Name, method.ResponseType.Name, method.CallCount),
})
}

Expand Down
19 changes: 12 additions & 7 deletions cmd/monitor/page_services_main.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package main

import (
"fmt"
"strconv"

"github.com/DownerCase/ecal-go/ecal/monitoring"
"github.com/charmbracelet/bubbles/table"
tea "github.com/charmbracelet/bubbletea"

"github.com/DownerCase/ecal-go/ecal/monitoring"
)

type ModelServicesMain struct {
Expand Down Expand Up @@ -39,13 +39,18 @@ func (m *ModelServicesMain) View() string {
return baseStyle.Render(m.table.View()) + "\n" + m.table.HelpView()
}

func (m *ModelServicesMain) GetSelectedID() (string, bool, error) {
func (m *ModelServicesMain) GetSelectedID() (uint64, bool, error) {
row := m.table.SelectedRow()
if row == nil {
return "", false, errEmptyTable
return 0, false, errEmptyTable
}

id, err := strconv.ParseUint(row[0], 10, 64)
if err != nil {
err = fmt.Errorf("services - GetSelectedID() %w", err)
}

return row[0], row[1] == "S", nil
return id, row[1] == "S", err
}

func (m *ModelServicesMain) updateTable(msg tea.Msg) tea.Cmd {
Expand Down Expand Up @@ -78,14 +83,14 @@ func serviceToRow(service monitoring.ServiceBase) table.Row {

func clientToRow(client monitoring.ClientMon) table.Row {
return append(
[]string{client.ID, "C"},
[]string{strconv.FormatUint(client.ID, 10), "C"},
serviceToRow(client.ServiceBase)...,
)
}

func serverToRow(server monitoring.ServerMon) table.Row {
return append(
[]string{server.ID, "S"},
[]string{strconv.FormatUint(server.ID, 10), "S"},
serviceToRow(server.ServiceBase)...,
)
}
4 changes: 2 additions & 2 deletions cmd/monitor/page_topics_detailed.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

type ModelTopicDetailed struct {
table table.Model
id string `exhaustruct:"optional"`
id uint64 `exhaustruct:"optional"`
topicType TopicType `exhaustruct:"optional"`
}

Expand All @@ -25,7 +25,7 @@ func NewDetailedModel() *ModelTopicDetailed {
}
}

func (m *ModelTopicDetailed) ShowTopic(topicID string, topicType TopicType) {
func (m *ModelTopicDetailed) ShowTopic(topicID uint64, topicType TopicType) {
m.id = topicID
m.topicType = topicType
m.updateDetailedTable(nil)
Expand Down
Loading

0 comments on commit 5d57ea5

Please sign in to comment.