Skip to content

Commit

Permalink
Update device name parameter to comply with API v4 and supervisor v7
Browse files Browse the repository at this point in the history
This change also makes the Docker build process more intuitive, cross-compiling
the ENM binary as part of the build.

change-type: major
  • Loading branch information
LucianBuzzo committed Mar 26, 2018
1 parent 21e1dab commit 257e653
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 11 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
@@ -0,0 +1,12 @@
# editorconfig.org
root = true

[*]
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
33 changes: 23 additions & 10 deletions Dockerfile.template
@@ -1,7 +1,28 @@
# Define a reusable argument containing the path to the go project
# see: https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
ARG PROJECT_DIR=/go/src/github.com/resin-io/edge-node-manager

# Build source using an image that has Go and Glide
FROM billyteves/alpine-golang-glide:1.2.0 as GO

ARG PROJECT_DIR

RUN mkdir -p $PROJECT_DIR
COPY . $PROJECT_DIR
WORKDIR $PROJECT_DIR

# Use Glide to install Go dependencies
RUN glide install

# Cross compile the ENM binary
RUN env GOOS=linux GOARCH=arm go build

# Debian base-image
# See more about resin base images here: http://docs.resin.io/runtime/resin-base-images/
FROM resin/%%RESIN_MACHINE_NAME%%-debian

ARG PROJECT_DIR

# Disable systemd init system
ENV INITSYSTEM off

Expand All @@ -18,16 +39,8 @@ RUN if [ "%%RESIN_MACHINE_NAME%%" = "raspberrypi3" ]; then export EXTRA_PACKAGES
jq && \
apt-get clean && rm -rf /var/lib/apt/lists/*

# Get the edge-node-manager binary, rename and make executable
RUN TAG=$(curl https://api.github.com/repos/resin-io/edge-node-manager/releases/latest -s | jq .tag_name -r) && \
echo "Pulling $TAG of the edge-node-manager binary for %%RESIN_ARCH%%" && \
curl -k -O https://resin-production-downloads.s3.amazonaws.com/edge-node-manager/$TAG/edge-node-manager-$TAG-linux-%%RESIN_ARCH%% && \
mv edge-node-manager-$TAG-linux-%%RESIN_ARCH%% edge-node-manager && \
chmod +x edge-node-manager

# Alternatively cross-compile the binary locally (env GOOS=linux GOARCH=arm go build)
# and copy it into the working directory - good for development
# COPY edge-node-manager ./
# Copy the cross-compiled binary into the working directory
COPY --from=GO $PROJECT_DIR/edge-node-manager ./

# The edge-node-manager will run when container starts up on the device
CMD ["./edge-node-manager"]
2 changes: 1 addition & 1 deletion supervisor/supervisor.go
Expand Up @@ -301,7 +301,7 @@ func DependentDeviceProvision(applicationUUID int) (resinUUID, name string, errs
}

resinUUID = buffer["uuid"].(string)
name = buffer["name"].(string)
name = buffer["device_name"].(string)

return
}
Expand Down

0 comments on commit 257e653

Please sign in to comment.