-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
simplify docker build and container init (#207)
- Loading branch information
1 parent
c67ccad
commit 54853b3
Showing
8 changed files
with
160 additions
and
137 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
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,59 @@ | ||
#!/usr/bin/env bash | ||
|
||
# build.sh | ||
# | ||
# Build the Synse Server docker images (slim and full) with the | ||
# appropriate tags. | ||
# | ||
# This script is intended to be called via the project Makefile | ||
# or CI workflow where the environment variables are managed. | ||
# | ||
|
||
red="\033[0;31m" | ||
green="\033[0;32m" | ||
nc="\033[0m" | ||
|
||
if [ ! "${IMAGE_NAME}" ]; then | ||
echo -e "${red}error: no image name specified for build${nc}" | ||
exit 1 | ||
fi | ||
|
||
if [ ! "${IMAGE_TAGS}" ]; then | ||
echo -e "${red}error: no image tags specified for build${nc}" | ||
exit 1 | ||
fi | ||
|
||
image="${IMAGE_NAME}" | ||
tags="${IMAGE_TAGS}" | ||
version=$(python -c "import synse ; print(synse.__version__)") | ||
build_date=$(date -u +%Y-%m-%dT%T 2> /dev/null) | ||
git_commit=$(git rev-parse --short HEAD 2> /dev/null || true) | ||
|
||
echo "+ Building Synse Server Images +" | ||
echo "--------------------------------" | ||
echo " image: ${image}" | ||
echo " version: ${version}" | ||
echo " tags: ${tags}" | ||
echo " date: ${build_date}" | ||
echo " commit: ${git_commit}" | ||
echo "--------------------------------" | ||
|
||
|
||
for tag in ${tags}; do | ||
echo -e "${green}tag: ${image}:${tag}[-slim]${nc}" | ||
|
||
# build the SLIM version of the tag | ||
docker build -f dockerfile/synse.dockerfile \ | ||
--build-arg BUILD_DATE=${build_date} \ | ||
--build-arg BUILD_VERSION=${version} \ | ||
--build-arg VCS_REF=${git_commit} \ | ||
--target=slim \ | ||
-t "${image}:${tag}-slim" . | ||
|
||
# build the FULL verison of the tag | ||
docker build -f dockerfile/synse.dockerfile \ | ||
--build-arg BUILD_DATE=${build_date} \ | ||
--build-arg BUILD_VERSION=${version} \ | ||
--build-arg VCS_REF=${git_commit} \ | ||
-t "${image}:${tag}" . | ||
done |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,95 @@ | ||
# | ||
# release.dockerfile | ||
# | ||
# The Dockerfile for the release build of Synse Server. This | ||
# Dockerfile has multiple stages: | ||
# * base: defines the base image and adds image metadata | ||
# * builder: build synse server package dependencies | ||
# * slim: a synse server build without emulator | ||
# * full: a synse server build with emulator | ||
# | ||
|
||
# | ||
# BASE | ||
# | ||
FROM python:3.6-alpine as base | ||
LABEL maintainer="Vapor IO" | ||
|
||
|
||
# | ||
# BUILDER | ||
# | ||
FROM python:3.6-alpine as builder | ||
|
||
RUN mkdir /build | ||
WORKDIR /build | ||
|
||
COPY requirements.txt /requirements.txt | ||
|
||
RUN set -e -x \ | ||
&& apk --update --no-cache --virtual .build-dep add \ | ||
build-base \ | ||
&& pip install --upgrade pip \ | ||
&& pip install --prefix=/build -r /requirements.txt --no-warn-script-location \ | ||
&& rm -rf /root/.cache \ | ||
&& apk del .build-dep | ||
|
||
|
||
# | ||
# SLIM | ||
# | ||
FROM base as slim | ||
COPY --from=builder /build /usr/local | ||
|
||
RUN set -e -x \ | ||
&& apk --update --no-cache add \ | ||
bash libstdc++ ca-certificates tini | ||
|
||
# Set image metadata (see: http://label-schema.org/rc1/) | ||
ARG BUILD_VERSION | ||
ARG BUILD_DATE | ||
ARG VCS_REF | ||
|
||
LABEL org.label-schema.schema-version="1.0" \ | ||
org.label-schema.build-date=$BUILD_DATE \ | ||
org.label-schema.name="vaporio/synse-server" \ | ||
org.label-schema.vcs-url="https://github.com/vapor-ware/synse-server" \ | ||
org.label-schema.vcs-ref=$VCS_REF \ | ||
org.label-schema.vendor="Vapor IO" \ | ||
org.label-schema.version=$BUILD_VERSION | ||
|
||
COPY . /synse | ||
WORKDIR /synse | ||
|
||
# Create directories for plugin sockets and configuration, then | ||
# install Synse Server as a python package | ||
RUN mkdir -p /tmp/synse/procs \ | ||
&& mkdir -p /synse/config \ | ||
&& pip install . \ | ||
&& rm -rf /root/.cache | ||
|
||
ENTRYPOINT ["/sbin/tini", "--", "bin/synse.sh"] | ||
|
||
|
||
# | ||
# FULL | ||
# | ||
FROM slim as full | ||
|
||
# Emulator installation script | ||
COPY bin/install_emulator.sh tmp/install_emulator.sh | ||
|
||
# Environment variables for built-in emulator configuration. | ||
ENV PLUGIN_DEVICE_CONFIG="/synse/emulator/config/device" \ | ||
PLUGIN_CONFIG="/synse/emulator" | ||
|
||
# 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 set -e -x \ | ||
&& mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2 \ | ||
&& apk --update --no-cache --virtual .build-dep add \ | ||
curl jq \ | ||
&& EMULATOR_OUT=/usr/local/bin/emulator ./tmp/install_emulator.sh \ | ||
&& apk del .build-dep |
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
""" | ||
|
||
__title__ = 'synse' | ||
__version__ = '2.1.0' | ||
__version__ = '2.1.1' | ||
__description__ = 'Synse Server' | ||
__author__ = 'Vapor IO' | ||
__author_email__ = '[email protected]' | ||
|