Skip to content

Commit 1d537fc

Browse files
authored
feat: add debian package builder
* feat: add debian package builder * add install docker script * make format happier * remove todo * add service restart * move docker install script in debian folder * implement multiarch build * build multi arch deb
1 parent 46f5dc3 commit 1d537fc

File tree

10 files changed

+88
-7
lines changed

10 files changed

+88
-7
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ go.work.sum
2828
.bin/
2929

3030
.venv/
31+
32+
build/

cmd/hello/main.go

Lines changed: 0 additions & 7 deletions
This file was deleted.

cmd/orchestrator/main.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"time"
6+
)
7+
8+
func main() {
9+
for {
10+
fmt.Println("running...")
11+
time.Sleep(1 * time.Second)
12+
}
13+
}

debian/Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM golang:1.24.2 AS go
2+
3+
COPY . /app
4+
WORKDIR /app
5+
RUN GOOS=linux go build -o orchestrator ./cmd/orchestrator/
6+
7+
FROM debian:bookworm AS debian
8+
9+
ARG VERSION="1.0.0"
10+
ARG REVISION="1"
11+
12+
RUN apt-get update && apt-get install -y sed
13+
14+
COPY ./debian/orchestrator /orchestrator/
15+
COPY --from=go /app/orchestrator /orchestrator/usr/bin/orchestrator
16+
17+
RUN sed -i "s/ARCH/$(dpkg --print-architecture)/" /orchestrator/DEBIAN/control && \
18+
dpkg-deb --build --root-owner-group /orchestrator &&\
19+
mv /orchestrator.deb "/orchestrator_${VERSION}-${REVISION}_$(dpkg --print-architecture).deb"
20+
21+
FROM scratch
22+
23+
COPY --from=debian /*.deb /

debian/install-docker-arm64.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
set -e
3+
4+
BASE_URL="https://download.docker.com/linux/debian/dists/bookworm/pool/stable/arm64"
5+
6+
cd /tmp
7+
8+
apt-get update
9+
10+
wget "$BASE_URL/containerd.io_1.7.27-1_arm64.deb"
11+
apt-get install ./containerd.io_1.7.27-1_arm64.deb
12+
13+
wget "$BASE_URL/docker-ce_28.0.4-1~debian.12~bookworm_arm64.deb"
14+
apt-get install ./docker-ce_28.0.4-1~debian.12~bookworm_arm64.deb
15+
16+
wget "$BASE_URL/docker-compose-plugin_2.34.0-1~debian.12~bookworm_arm64.deb"
17+
apt-get install ./docker-compose-plugin_2.34.0-1~debian.12~bookworm_arm64.deb
18+
19+
echo "Docker installed successfully."
20+

debian/orchestrator/DEBIAN/control

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Package: arduino-orchestrator
2+
Version: 1.0
3+
Architecture: ARCH
4+
Maintainer: arduino <support@arduino.cc>
5+
Description: Arduino application orchestrator
6+
Depends: docker-ce, containerd.io, docker-compose-plugin
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
3+
systemctl daemon-reload
4+
systemctl enable arduino-orchestrator
5+
systemctl start arduino-orchestrator

debian/orchestrator/DEBIAN/postrm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
systemctl daemon-reload

debian/orchestrator/DEBIAN/prerm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
3+
systemctl disable arduino-orchestrator
4+
systemctl stop arduino-orchestrator
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[Unit]
2+
Description=Arduino Orchestrator Service
3+
4+
[Service]
5+
ExecStart=/usr/bin/orchestrator
6+
StandardOutput=journal
7+
StandardError=journal
8+
Restart=always
9+
RestartSec=3
10+
11+
[Install]
12+
WantedBy=multi-user.target

0 commit comments

Comments
 (0)