-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
41b3fae
commit 0229dcf
Showing
5 changed files
with
51 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,34 @@ | ||
# Build the NetDaemon with build container | ||
FROM mcr.microsoft.com/dotnet/core/sdk:3.1.200-alpine as build | ||
|
||
COPY . ./temp/ | ||
|
||
RUN \ | ||
mkdir -p /data \ | ||
\ | ||
&& dotnet \ | ||
publish \ | ||
./temp/src/Service/Service.csproj \ | ||
-c Release \ | ||
-o ./temp/dist \ | ||
\ | ||
&& mv ./temp/dist /app \ | ||
&& rm -R ./temp | ||
RUN apk add \ | ||
bash | ||
|
||
# Copy the source to docker container | ||
COPY ./src /tmp/src | ||
|
||
# Copy the build script for minimal single binary build | ||
COPY addon/rootfs/build/build.sh /tmp/build.sh | ||
RUN chmod +x /tmp/build.sh | ||
|
||
# Build the minimal single binary | ||
RUN /bin/bash /tmp/build.sh | ||
|
||
# Build the target container | ||
FROM ludeeus/container:dotnet-base | ||
FROM netdaemon/base | ||
|
||
# Copy the built binaries and set execute permissions | ||
COPY --from=build /netdaemon/bin/publish /daemon | ||
RUN chmod +x /daemon/Service | ||
|
||
COPY --from=build /app /app | ||
# Copy the S6 service scripts | ||
COPY addon/rootfs/etc /etc | ||
|
||
# Set default values of NetDaemon env | ||
ENV \ | ||
HASS_HOST=localhost \ | ||
HASS_PORT=8123 \ | ||
HASS_TOKEN=NOT_SET \ | ||
HASS_DAEMONAPPFOLDER=/data | ||
|
||
ENTRYPOINT ["dotnet", "/app/Service.dll"] | ||
ENTRYPOINT ["/init"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
cd /tmp | ||
|
||
ARC=$(uname -m) | ||
|
||
echo "Building NetDaemon for platform $ARC" | ||
|
||
if [ "$ARC" == "armhf" ]; then | ||
export RID="linux-arm" | ||
elif [ "$ARC" == "aarch64" ]; then | ||
export RID="linux-arm" | ||
elif [ "$ARC" == "x86_64" ]; then | ||
export RID="linux-x64" | ||
else | ||
echo 'NOT VALID ARCHITECTURE' && exit 1 | ||
|
||
fi | ||
|
||
cd src/Service/ | ||
dotnet add package Microsoft.Packaging.Tools.Trimming --version 1.1.0-preview1-26619-01 | ||
dotnet publish -c Release -o /netdaemon/bin/publish -r $RID /p:PublishSingleFile=true /p:PublishTrimmed=true /p:TrimUnusedDependencies=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
#!/usr/bin/with-contenv bashio | ||
#!/usr/bin/with-contenv /bin/bash | ||
|
||
# ============================================================================== | ||
# NetDaemon Add-on | ||
# NetDaemon Service | ||
# Starts NetDaemon | ||
# ============================================================================== | ||
cd /daemon || echo -e "\033[31mCould not change directory to daemon\033[0m" >&2 | ||
|
||
cd /daemon || bashio::exit.nok "Could not change directory to Node-RED" | ||
|
||
bashio::log.info "Starting NetDaemon..." | ||
echo -e "\033[32mStarting NetDaemon...\033[0m" >&2 | ||
|
||
exec ./Service | ||
./Service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters