-
Notifications
You must be signed in to change notification settings - Fork 125
/
Copy pathsnapcraft.yaml
99 lines (89 loc) · 4.07 KB
/
snapcraft.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: edgex-device-simple
# The snap to derive the runtime rootfs from, here core18 corresponds to a
# minimal Ubuntu 18.04 Server rootfs
base: core18
type: app
adopt-info: version
license: Apache-2.0
title: EdgeX Simple Device Service
summary: Demonstrate the Device SDK go in EdgeX using device-simple
description: |
device-simple is an example EdgeX Device Service built using the
device-sdk-go.
# delhi: 0, edinburgh: 1, fuji: 2, geneva: 3, ireland: 4
epoch: 4
# What architectures to build the snap on
architectures:
- build-on: amd64
- build-on: arm64
# The "stability" of the snap and what users can expect from it
# Note that "devel" grade cannot be released to stable or candidate channels
grade: stable
confinement: strict
apps:
device-simple:
# `adapter` specifies what kind of environment variables need to be setup
# for the app, since our app is a statically compiled go app, we don't
# need any of the env vars, but if this was a c program or used cgo, we
# would need adapter: full
adapter: none
command: bin/device-simple --registry $CONFIG_PRO_ARG $CONF_ARG
# Since we can't include the colon ':' characters in the command above,
# we need to specify the consul address in an env var like so
# see https://bugs.launchpad.net/snapd/+bug/1827392 for more details
environment:
CONFIG_PRO_ARG: "--cp=consul.http://localhost:8500"
CONF_ARG: "--configDir=$SNAP_DATA/config/device-simple/res"
DEVICE_DEVICESDIR: "$SNAP_DATA/config/device-simple/res/devices"
DEVICE_PROFILESDIR: "$SNAP_DATA/config/device-simple/res/profiles"
# The service is a simple service that is directly exec'd and expected to
# always run in a single long-lived process
daemon: simple
# Use network and network-bind plugs to access the network and bind to
# ports on network interfaces
plugs: [network, network-bind]
parts:
version:
plugin: nil
source: snap/local
override-pull: |
cd $SNAPCRAFT_PROJECT_DIR
GIT_VERSION=$(git describe --tags --abbrev=0 | sed 's/v//')
snapcraftctl set-version ${GIT_VERSION}
device-simple:
source: .
plugin: make
build-packages: [git, libzmq3-dev, zip, pkg-config]
build-snaps:
- go/1.16/stable
stage-packages: [libzmq5]
override-build: |
# Build device-simple first
cd $SNAPCRAFT_PART_SRC
make build
# Copy the resulting binary into $SNAPCRAFT_PART_INSTALL in the build
# environment, which snapcraft will pack into $SNAP when the build is
# done.
install -DT "./example/cmd/device-simple/device-simple" \
"$SNAPCRAFT_PART_INSTALL/bin/device-simple"
# "ProfilesDir" in combination with the confdir and profile command-line
# options are sufficient to not need to cd before exec'ing the binary.
# Change "ProfilesDir" to be under $SNAP_DATA which is writable and
# where the install hook copies the config files and device profiles to
# when the snap is first installed
install -DT "./example/cmd/device-simple/res/configuration.yaml" \
"$SNAPCRAFT_PART_INSTALL/config/device-simple/res/configuration.yaml"
# Install the example device and device profile
install -DT "./example/cmd/device-simple/res/devices/simple-device.toml" \
"$SNAPCRAFT_PART_INSTALL/config/device-simple/res/devices/simple-device.toml"
install -DT "./example/cmd/device-simple/res/profiles/Simple-Driver.yaml" \
"$SNAPCRAFT_PART_INSTALL/config/device-simple/res/profiles/Simple-Driver.yaml"
# Also install the Attribution.txt and LICENSE files into the snap at
# usr/share/doc/device-simple which is a debian standard location for
# licenses in the snap.
# Note also if the license is changed that the license key in the
# metadata for the snap at the top of this file should be updated too.
install -DT "./example/cmd/device-simple/Attribution.txt" \
"$SNAPCRAFT_PART_INSTALL/usr/share/doc/device-simple/Attribution.txt"
install -DT "./LICENSE" \
"$SNAPCRAFT_PART_INSTALL/usr/share/doc/device-simple/LICENSE"