Skip to content

Commit

Permalink
update dockerfile to download emulator from github release (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
edaniszewski committed Apr 16, 2018
1 parent 5fdc2aa commit 38b6c0a
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 82 deletions.
6 changes: 6 additions & 0 deletions .dockerignore.default → .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,20 @@ logs/
Dockerfile.*
**/*.dockerfile

# Deployment Configs
deploy/

# Docs
docs/
**/*.md
**/*.rst
NOTICE

# Images
**/*.png

# Test Artifacts
prof/
results/
.circleci/
.coverage
61 changes: 0 additions & 61 deletions .dockerignore.slim

This file was deleted.

6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,16 @@ pycache-clean:
# build the docker images of synse server without the emulator
.PHONY: docker-slim
docker-slim:
cp .dockerignore.slim .dockerignore
tags="" ; \
for tag in $(SLIM_TAGS); do tags="$${tags} -t $${tag}"; done ; \
docker build -f dockerfile/release.dockerfile $${tags} .
rm .dockerignore
docker build -f dockerfile/slim.dockerfile $${tags} .

# build the docker images of synse server with the emulator
.PHONY: docker-default
docker-default:
cp .dockerignore.default .dockerignore
tags="" ; \
for tag in $(DEFAULT_TAGS); do tags="$${tags} -t $${tag}"; done ; \
docker build -f dockerfile/release.dockerfile $${tags} .
rm .dockerignore


# Targets
Expand Down
7 changes: 5 additions & 2 deletions bin/synse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,11 @@ function -v {
# start the background process emulator using the emulator
# configurations found in /synse/synse/emulator/config
function enable-emulator {
if [ -d emulator ]; then
(cd emulator ; PLUGIN_DEVICE_CONFIG=config ./emulator 1>&2 &)
if [ "$(which emulator)" ]; then
# the emulator binary is downloaded and installed into /usr/local/bin
# in the dockerfile. the configs for it are set via ENV variable in
# the dockerfile as well.
emulator 1>&2 &
else
echo "This Synse Server image does not contain the emulator."
echo "Try using a non 'slim' Synse Server image for emulator"
Expand Down
24 changes: 21 additions & 3 deletions dockerfile/release.dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,39 @@
FROM python:3.6-alpine
MAINTAINER Vapor IO <vapor@vapor.io>

# Environment variables for downloading the emulator plugin
ENV EMULATOR_REPO vapor-ware/synse-emulator-plugin
ENV EMULATOR_BIN emulator_linux_amd64

# Environment variables for built-in emulator configuration.
ENV PLUGIN_DEVICE_CONFIG /synse/emulator/config
ENV PLUGIN_CONFIG /synse/emulator

COPY ./requirements.txt requirements.txt

# The linux_amd64 emulator binary is built with libc, not muslc, it
# will not work here. The musl and glibc so files are compatible, so
# we can make a symlink to fix the missing dependency:
# https://stackoverflow.com/a/35613430
RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2

RUN set -e -x \
&& apk --update --no-cache add \
bash gcc curl \
bash libstdc++ \
&& apk --update --no-cache --virtual .build-dep add \
build-base \
curl build-base jq \
&& pip install --upgrade pip \
&& pip install -r requirements.txt \
&& bin_url=$(curl -s https://api.github.com/repos/${EMULATOR_REPO}/releases/latest | jq '.assets[] | select(.name == env.EMULATOR_BIN) | .url' | tr -d '"') \
&& curl -L -H "Accept: application/octet-stream" -o $EMULATOR_BIN $bin_url \
&& chmod +x $EMULATOR_BIN \
&& mv $EMULATOR_BIN /usr/local/bin/emulator \
&& apk del .build-dep

COPY . /synse
WORKDIR /synse

# create directories for plugin sockets and configuration
# Create directories for plugin sockets and configuration
RUN mkdir -p /tmp/synse/procs \
&& mkdir -p /synse/config

Expand Down
29 changes: 29 additions & 0 deletions dockerfile/slim.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM python:3.6-alpine
MAINTAINER Vapor IO <vapor@vapor.io>

COPY requirements.txt requirements.txt

RUN set -e -x \
&& apk --update --no-cache add \
bash libstdc++ \
&& apk --update --no-cache --virtual .build-dep add \
build-base \
&& pip install --upgrade pip \
&& pip install -r requirements.txt \
&& apk del .build-dep

COPY . /synse
WORKDIR /synse

# Create directories for plugin sockets and configuration
RUN mkdir -p /tmp/synse/procs \
&& mkdir -p /synse/config

# install synse_server python package
# TODO - since we are pretty much just using the package, what
# if on build, we just pass in the tarball for synse_server.. then
# we don't have to also include the source code which isn't actually
# used (other than some of the configurations and runserver.py
RUN python setup.py install

ENTRYPOINT ["bin/synse.sh"]
10 changes: 0 additions & 10 deletions emulator/README.md

This file was deleted.

7 changes: 6 additions & 1 deletion emulator/config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# Configuration for the emulator plugin built-in to Synse Server
version: 1.0
name: emulator
debug: true
network:
type: unix
address: emulator.sock
settings:
loop_delay: 1000 # run the loop on a 1s delay
mode: parallel
read:
interval: 1s
write:
interval: 1s
Binary file removed emulator/emulator
Binary file not shown.

0 comments on commit 38b6c0a

Please sign in to comment.