diff --git a/README.md b/README.md index 07e8be3..3467757 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ All platforms are available in Docker Hub: * tsuru/python3: https://hub.docker.com/r/tsuru/python3/ * tsuru/pypy: https://hub.docker.com/r/tsuru/pypy/ * tsuru/ruby: https://hub.docker.com/r/tsuru/ruby/ +* tsuru/rust: https://hub.docker.com/r/tsuru/rust/ * tsuru/static: https://hub.docker.com/r/tsuru/static/ Installing platforms @@ -60,3 +61,10 @@ We provide a base image which platform developers can use to build upon: a base deployment script, which handles package downloading and extraction in proper path, along with operating system package management. For more details, check the README of base-platform. + +To update a platform: + + docker rmi 127.0.0.1:5000/rust + docker build -t 127.0.0.1:5000/rust . + docker push 127.0.0.1:5000/rust + tsuru-admin platform-update rust -i 127.0.0.1:5000/rust diff --git a/rust/Dockerfile b/rust/Dockerfile new file mode 100644 index 0000000..433d114 --- /dev/null +++ b/rust/Dockerfile @@ -0,0 +1,11 @@ +# Copyright 2016 tsuru authors. All rights reserved. +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file. + +FROM tsuru/base-platform +RUN pwd +RUN ls +RUN ls . +ADD . /var/lib/tsuru/rust +RUN cp /var/lib/tsuru/rust/deploy /var/lib/tsuru +RUN /var/lib/tsuru/rust/install diff --git a/rust/Procfile b/rust/Procfile new file mode 100644 index 0000000..2e19ada --- /dev/null +++ b/rust/Procfile @@ -0,0 +1 @@ +web: %web% diff --git a/rust/README.md b/rust/README.md new file mode 100644 index 0000000..e654ac7 --- /dev/null +++ b/rust/README.md @@ -0,0 +1,11 @@ +# Rust Platform + +The Rust platform supports code deployment, the application is built in the +target. + + +## Code deployment + +If you just run a ``git push`` of your code, tsuru will try and build the +application using ``cargo build`` – which fetches all the dependencies +automatically. diff --git a/rust/deploy b/rust/deploy new file mode 100755 index 0000000..413f687 --- /dev/null +++ b/rust/deploy @@ -0,0 +1,24 @@ +#!/bin/bash -el + +# Copyright 2016 tsuru authors. All rights reserved. +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file. + +SOURCE_DIR=/var/lib/tsuru +source ${SOURCE_DIR}/base/deploy +source ${SOURCE_DIR}/base/rc/config + +if [ -f ${CURRENT_DIR}/Cargo.toml ]; then + pushd ${CURRENT_DIR} >/dev/null 2>&1 + # if [ ! -f ${CURRENT_DIR}/Procfile ]; then + if [ -f ${APP_DIR}/.default_procfile ]; then + echo "Procfile not found, using default one." + PKG_NAME=$(awk -F ' *= *' \ + '{if ($1 ~ /^\[package\]/) stop=1; else if ($1 ~ /^name$/ && stop){print $2; exit}}' \ + ${CURRENT_DIR}/Cargo.toml | cut -d\" -f2) + echo "Package name: $PKG_NAME" + sed s:%web%:$PKG_NAME: ${SOURCE_DIR}/default/Procfile > ${CURRENT_DIR}/Procfile + fi + cargo install --force --verbose + popd >/dev/null 2>&1 +fi diff --git a/rust/install b/rust/install new file mode 100755 index 0000000..8c618ca --- /dev/null +++ b/rust/install @@ -0,0 +1,26 @@ +#!/bin/bash -el + +# Copyright 2016 tsuru authors. All rights reserved. +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file. + +SOURCE_DIR=/var/lib/tsuru +source ${SOURCE_DIR}/base/rc/config + +# As of 2016-07-07 `file` is needed. Please check: +# https://github.com/rust-lang-nursery/rustup.rs/issues/466 +apt-get update && apt-get install -y file gcc git + +sh <(curl -sSf https://static.rust-lang.org/rustup.sh) --verbose -y --channel=stable + +cp ${SOURCE_DIR}/rust/Procfile ${SOURCE_DIR}/default/Procfile + +CARGO_HOME=${APP_DIR}/.cargo +mkdir -p ${CARGO_HOME}/bin +mkdir ${CARGO_HOME}/target + +echo "export CARGO_HOME=${CARGO_HOME}" >> ${HOME}/.profile +echo 'export CARGO_TARGET_DIR=$CARGO_HOME/target' >> ${HOME}/.profile +echo 'PATH=$CARGO_HOME/bin:$PATH' >> ${HOME}/.profile + +chown -R ${USER}:${USER} ${CARGO_HOME}