Skip to content

Commit

Permalink
Combine with dockerfiles_imageflow repository, reorganize
Browse files Browse the repository at this point in the history
  • Loading branch information
lilith committed Oct 2, 2018
1 parent 4cbf721 commit 67ccc86
Show file tree
Hide file tree
Showing 63 changed files with 1,360 additions and 718 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Exclude stuff from the docker build context

target
.docker_*/
12 changes: 6 additions & 6 deletions ci/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CI scripts


* **install_\*.sh scripts are not used! They are guidance if you need to install these components yourself**
* travis_install.sh is run first
* travis_run.sh is run next, which selects travis_run_docker.sh (run inside a docker container) or build.sh (run directly)
# CI scripts


* **install_\*.sh scripts are not used! They are guidance if you need to install these components yourself**
* travis_install.sh is run first
* travis_run.sh is run next, which selects travis_run_docker.sh (run inside a docker container) or build.sh (run directly)
2 changes: 0 additions & 2 deletions ci/docker/.dockerignore

This file was deleted.

16 changes: 0 additions & 16 deletions ci/docker/docker.md

This file was deleted.

2 changes: 0 additions & 2 deletions ci/docker/travis/ubuntu14/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions ci/docker/travis/ubuntu16/Dockerfile

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion ci/packaging_extras/requirements/x86_64-linux-musl.txt

This file was deleted.

1 change: 0 additions & 1 deletion ci/packaging_extras/requirements/x86_64-mac-osx10_11.txt

This file was deleted.

This file was deleted.

This file was deleted.

41 changes: 41 additions & 0 deletions ci/travis_monitor_base_dockerfiles.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
# script expects TRAVIS_COMMIT_RANGE to be set to a commit range to check for changes
# and TRAVIS_BUILD_DIR set to the build dir
# Docker hub only triggers if $TRAVIS_BRANCH or $TRAVIS_TAG are set

# first param is file to monitor for changes
# second is endpoint to inform
inform_docker_hub_if_changed(){

if [ -z "$1" ]; then
echo "First parameter must be a file to diff for changes. Exiting." && exit 1;
fi
if [ -z "$2" ]; then
echo "Second parameter must be a docker hub endpoint. Exiting." && exit 1;
fi

if [ -z "${TRAVIS_COMMIT_RANGE}" ]; then
echo "TRAVIS_COMMIT_RANGE not set - should be commit range to check for changes, like 6544f0b..a62c029. Exiting." && exit 1;
else
echo "Scanning ${TRAVIS_COMMIT_RANGE} for changes to $1";
git diff -s --exit-code ${TRAVIS_COMMIT_RANGE} ./README.m
RETVAL = $?
if [ RETVAL -eq 1 ]; then
echo ... found changes, invoking travis_trigger_docker_cloud.sh
./ci/travis_trigger_docker_cloud.sh "$2"
elif [ RETVAL -eq 0 ]; then
echo ... no changes
else
echo ... git command failed with error ${RETVAL}
fi

fi
}

cd "$TRAVIS_BUILD_DIR"

#inform_docker_hub_if_changed("./docker/imageflow_base_os/Dockerfile","")
#inform_docker_hub_if_changed("./docker/imageflow_build_ubuntu16/Dockerfile","")
#inform_docker_hub_if_changed("./docker/imageflow_build_ubuntu18/Dockerfile","")
inform_docker_hub_if_changed "./docker/imageflow_build_ubuntu18_debug/Dockerfile" "https://registry.hub.docker.com/u/imazen/imageflow_build_ubuntu18_debug/trigger/38852860-517f-49c2-81c2-a033aba36a5b/"

28 changes: 11 additions & 17 deletions ci/travis_trigger_docker_cloud.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
#!/bin/bash
set -e #Exit on failure.

if [ -z "$1" ]; then
echo "travis_trigger_docker_hub.sh requires a docker hub endpoint url as a parameter. Exiting." && exit 1;
fi

# Test locally by running
# TRAVIS_BRANCH=master ./ci/travis_trigger_docker_cloud.sh
# TRAVIS_TAG=v0.0.10 ./ci/travis_trigger_docker_cloud.sh
# TRAVIS_BRANCH=master ./ci/travis_trigger_docker_cloud.sh https://registry.hub.docker.com/u/imazen/imageflow_server_unsecured/trigger/3682f725-3a98-49dd-9e96-acd594721250/
# TRAVIS_TAG=v0.0.10 ./ci/travis_trigger_docker_cloud.sh https://registry.hub.docker.com/u/imazen/imageflow_tool/trigger/d4943bd2-6350-4cda-9012-f56fe2deaef8/

if [[ -z "$TRAVIS_PULL_REQUEST_SHA" ]]; then
if [[ -n "$TRAVIS_TAG" ]]; then
# We can re-enable when tagged releases allow non-localhost connections
#export CLOUD_SOURCE_NAME="${TRAVIS_TAG}"
#export CLOUD_SOURCE_TYPE="Tag"
echo "Skipping docker cloud build for tags (update when we permit non-localhost connections)"
export CLOUD_SOURCE_NAME="${TRAVIS_TAG}"
export CLOUD_SOURCE_TYPE="Tag"
else
if [[ -n "$TRAVIS_BRANCH" ]]; then
export CLOUD_SOURCE_NAME="${TRAVIS_BRANCH}"
Expand All @@ -22,17 +24,9 @@ fi
if [[ -n "$CLOUD_SOURCE_NAME" ]]; then
PAYLOAD="{'source_type': '${CLOUD_SOURCE_TYPE}', 'source_name': '${CLOUD_SOURCE_NAME}'}"

# This token has no security value and is rate limited to 10.
# Endpoint url tokens have no security value and are rate limited to 10.
# It only checks GitHub for the given tag/branch - it does not accept any data.
TRIGGER_ENDPOINT=https://registry.hub.docker.com/u/imazen/imageflow_server_unsecured/trigger/3682f725-3a98-49dd-9e96-acd594721250/
echo "Trigger 1 (server): docker cloud build with $PAYLOAD"
curl -H "Content-Type: application/json" --data "${PAYLOAD}" -X POST "$TRIGGER_ENDPOINT"

TRIGGER_ENDPOINT_2=https://registry.hub.docker.com/u/imazen/imageflow_tool/trigger/d4943bd2-6350-4cda-9012-f56fe2deaef8/

echo "Trigger 2 (imageflow_tool) docker cloud build with $PAYLOAD"
curl -H "Content-Type: application/json" --data "${PAYLOAD}" -X POST "$TRIGGER_ENDPOINT_2"


echo "Invoking $1 with $PAYLOAD"
curl -H "Content-Type: application/json" --data "${PAYLOAD}" -X POST "$1"
fi

56 changes: 28 additions & 28 deletions ci/wintools/SETUP_PATH.bat
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
echo PATH is currently: %PATH%
echo .
echo .
set PATH=%PATH%;C:\Program Files\Git\bin;C:\Program Files\Git\mingw64\bin
set PATH=%PATH%;C:\Program Files (x86)\NASM;
set PATH=%PATH%;C:\Program Files (x86)\Rust\bin

echo Updated path to
echo %PATH%
echo .

set RUST_TARGET=i686-pc-windows-msvc
set TARGET_CPU=sandybridge
set RUST_FLAGS=%RUST_FLAGS -C target-cpu=%TARGET_CPU%

set CARGO_INCREMENTAL=1
set RUST_TEST_THREADS=1
set VS_ARCH=x86

if [%1] == [x86] goto :x86
set RUST_TARGET=x86_64-pc-windows-msvc
set VS_ARCH=amd64
:x86

echo VS_ARCH=%VSARCH% RUST_TARGET=%RUST_TARGET% TARGET_CPU=%TARGET_CPU% CARGO_INCREMENTAL=%CARGO_INCREMENTAL%
echo NOW entering VS 14

%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %VS_ARCH%"
echo PATH is currently: %PATH%
echo .
echo .
set PATH=%PATH%;C:\Program Files\Git\bin;C:\Program Files\Git\mingw64\bin
set PATH=%PATH%;C:\Program Files (x86)\NASM;
set PATH=%PATH%;C:\Program Files (x86)\Rust\bin

echo Updated path to
echo %PATH%
echo .

set RUST_TARGET=i686-pc-windows-msvc
set TARGET_CPU=sandybridge
set RUST_FLAGS=%RUST_FLAGS -C target-cpu=%TARGET_CPU%

set CARGO_INCREMENTAL=1
set RUST_TEST_THREADS=1
set VS_ARCH=x86

if [%1] == [x86] goto :x86
set RUST_TARGET=x86_64-pc-windows-msvc
set VS_ARCH=amd64
:x86

echo VS_ARCH=%VSARCH% RUST_TARGET=%RUST_TARGET% TARGET_CPU=%TARGET_CPU% CARGO_INCREMENTAL=%CARGO_INCREMENTAL%
echo NOW entering VS 14

%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %VS_ARCH%"
21 changes: 21 additions & 0 deletions docker/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017-2018 Imazen

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
43 changes: 43 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Dockerfiles


## for running Imageflow

* imageflow_tool
* imageflow_server_unsecured
* proxied_stack

## for building Imageflow

All Dockerfiles should use user account `imageflow` with uid 1000
Build directory should be /home/imageflow/imageflow
Run directory should be /home/imageflow

* imageflow_base_os is for lightweight deployment; it is not used during build.
* imageflow_build_ubuntu16
* imageflow_build_ubuntu18
* imageflow_build_ubuntu18_debug

## Building

No special requirements. The build scripts are there for convenience.

## Testing

Clone imazen/imageflow, and invoke ./ci/docker/test.sh [imagename] `imazen/` is auto-prefixed to the first argument.


## FAQ

### Cannot connect to the Docker daemon. Is the docker daemon running on this host?

See https://stackoverflow.com/questions/21871479/docker-cant-connect-to-docker-daemon


OS X only:

```
docker-machine start # start virtual machine for docker
docker-machine env # it helps to get environment variables
eval "$(docker-machine env default)" #set environment variables
```
12 changes: 12 additions & 0 deletions docker/container_size.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

docker images

docker history imazen/imageflow_base_os
docker history imazen/imageflow_build_ubuntu14
docker history imazen/imageflow_build_ubuntu16
docker history imazen/imageflow_build_ubuntu18
docker history imazen/imageflow_build_ubuntu18_debug

#docker run imazen/build_if_gcc48 du -h / | grep '[0-9\.]\+M'

36 changes: 36 additions & 0 deletions docker/imageflow_base_os/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM ubuntu:bionic

MAINTAINER Lilith River

ARG BASE_OS_SOURCE_COMMIT
ARG BASE_OS_DOCKER_TAG

RUN if [ -z "${BASE_OS_SOURCE_COMMIT}" ]; then echo "BASE_OS_SOURCE_COMMIT not set; exiting" && exit 1; else echo "BASE_OS_SOURCE_COMMIT=${BASE_OS_SOURCE_COMMIT}"; fi

RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install --no-install-recommends -y \
sudo wget libcurl4-openssl-dev curl libssl-dev ca-certificates libpng-dev \
&& apt-get clean -y \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/* \
&& bash -c 'rm -rf {/usr/share/doc,/usr/share/man,/var/cache,/usr/doc,/usr/local/share/doc,/usr/local/share/man}' \
&& bash -c 'rm -rf /tmp/*' \
&& bash -c 'rm -rf /var/tmp/*' \
&& sudo mkdir -p /var/cache/apt/archives/partial \
&& sudo touch /var/cache/apt/archives/lock \
&& sudo chmod 640 /var/cache/apt/archives/lock

RUN groupadd 1001 -g 1001 &&\
groupadd 1000 -g 1000 &&\
useradd -ms /bin/bash imageflow -g 1001 -G 1000 &&\
echo "imageflow:imageflow" | chpasswd && adduser imageflow sudo &&\
echo "imageflow ALL= NOPASSWD: ALL\n" >> /etc/sudoers

USER imageflow

WORKDIR /home/imageflow

ENV RUST_BACKTRACE 1
ENV BASE_OS_SOURCE_COMMIT="${BASE_OS_SOURCE_COMMIT}" BASE_OS_DOCKER_TAG="${BASE_OS_DOCKER_TAG}"
ENV BASE_OS_LAST_LAYER_UNIX_SECONDS="$(date +%s)"
10 changes: 10 additions & 0 deletions docker/imageflow_base_os/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## imazen/imageflow_base_os

* This image should contain the runtime dependencies needed by imageflow_server and imageflow_tool.
* It should also contain wget, for use in child dockerfiles
* RUST_BACKTRACE=1

It should be rebuilt every commit, master -> latest, (v[0-9].*) -> $1


ubuntu:bionic with imageflow user account - updated with sudo wget libcurl4-openssl-dev curl libssl-dev ca-certificates libpng-dev
15 changes: 15 additions & 0 deletions docker/imageflow_base_os/hooks/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

echo "SOURCE_COMMIT: $SOURCE_COMMIT"

if [[ -z "$SOURCE_COMMIT" ]]; then
export SOURCE_COMMIT="${SOURCE_COMMIT:-$(git rev-parse HEAD)}"
echo "Updating SOURCE_COMMIT from git rev-parse HEAD"
echo "SOURCE_COMMIT: $SOURCE_COMMIT"
fi

IMAGE_NAME="${IMAGE_NAME:-imazen/imageflow_base_os}"

echo "DOCKER_TAG: $DOCKER_TAG"

docker build -t "$IMAGE_NAME" --build-arg "BASE_OS_SOURCE_COMMIT=$SOURCE_COMMIT" --build-arg "BASE_OS_DOCKER_TAG=$DOCKER_TAG" .
Loading

0 comments on commit 67ccc86

Please sign in to comment.