-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use a docker launcher image to simplify start/stop/update/restart commands #1683
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Copyright (c) 2012-2016 Codenvy, S.A. | ||
# All rights reserved. This program and the accompanying materials | ||
# are made available under the terms of the Eclipse Public License v1.0 | ||
# which accompanies this distribution, and is available at | ||
# http://www.eclipse.org/legal/epl-v10.html | ||
# | ||
# Contributors: | ||
# Codenvy, S.A. - Initial implementation | ||
# | ||
# To build, in this directory: | ||
# `docker build -t codenvy/che-cli .` | ||
# | ||
# Use it to install files into current directory with Windows: | ||
# set f=%~dp0:\=/%&set h=%g::=%&set i=/%h% | ||
# for /l %%a in (1,1,100) do if "!i:~-1!"==" " set i=!i:~0,-1! | ||
# docker run -v %i%:/che codenvy/che-cli | ||
# | ||
# Use it to install files into current directory with Linux / Mac: | ||
# docker run -v $(pwd):/che codenvy/che-cli | ||
# | ||
FROM alpine:3.4 | ||
|
||
RUN apk add --no-cache \ | ||
ca-certificates \ | ||
curl \ | ||
openssl | ||
|
||
ENV DOCKER_BUCKET get.docker.com | ||
ENV DOCKER_VERSION 1.6.0 | ||
|
||
RUN set -x \ | ||
&& curl -sL "https://${DOCKER_BUCKET}/builds/Linux/x86_64/docker-$DOCKER_VERSION" \ | ||
> /usr/bin/docker; chmod +x /usr/bin/docker | ||
|
||
COPY files-to-install che | ||
|
||
COPY /install.sh /bin/install.sh | ||
|
||
ENTRYPOINT ["bin/install.sh"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
@REM | ||
@REM Copyright (c) 2012-2016 Codenvy, S.A. | ||
@REM All rights reserved. This program and the accompanying materials | ||
@REM are made available under the terms of the Eclipse Public License v1.0 | ||
@REM which accompanies this distribution, and is available at | ||
@REM http://www.eclipse.org/legal/epl-v10.html | ||
@REM | ||
@REM Contributors: | ||
@REM Codenvy, S.A. - initial API and implementation | ||
@REM | ||
|
||
@echo off | ||
|
||
REM Check to ensure bash is installed | ||
CALL bash --help > nul 2>&1 | ||
IF %ERRORLEVEL% NEQ 0 goto setup | ||
|
||
REM Launch Che and any associated docker machines, if necessary | ||
CALL bash --login -i "%~dp0\che.sh" %* | ||
|
||
goto end | ||
|
||
:setup | ||
echo. | ||
echo "REQUIRED: Git bash for Windows. It is typically stored c:\Program Files\Git\bin." | ||
echo. | ||
|
||
:end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
#!/bin/sh | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @l0rd Can you clarify why we need this script and https://github.com/eclipse/che/pull/1683/files#diff-358fea9821fbcf9770f2820a93c4c5ab. They are pretty similar. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's for the CLI. |
||
# Copyright (c) 2012-2016 Codenvy, S.A. | ||
# All rights reserved. This program and the accompanying materials | ||
# are made available under the terms of the Eclipse Public License v1.0 | ||
# which accompanies this distribution, and is available at | ||
# http://www.eclipse.org/legal/epl-v10.html | ||
|
||
init_logging() { | ||
BLUE='\033[1;34m' | ||
GREEN='\033[0;32m' | ||
RED='\033[0;31m' | ||
NC='\033[0m' | ||
} | ||
|
||
init_global_variables() { | ||
|
||
CHE_LAUNCHER_CONTAINER_NAME="che-launcher" | ||
CHE_LAUNCHER_IMAGE_NAME="che-launcher" | ||
|
||
# User configurable variables | ||
DEFAULT_CHE_VERSION="latest" | ||
DEFAULT_CHE_CLI_ACTION="help" | ||
|
||
CHE_VERSION=${CHE_VERSION:-${DEFAULT_CHE_VERSION}} | ||
CHE_CLI_ACTION=${CHE_CLI_ACTION:-${DEFAULT_CHE_CLI_ACTION}} | ||
|
||
USAGE=" | ||
Usage: | ||
che [COMMAND] | ||
start Starts Che server | ||
stop Stops Che server | ||
restart Restart Che server | ||
update Pull latest version of ${CHE_LAUNCHER_IMAGE_NAME} | ||
info Print some debugging information | ||
|
||
Docs: http://eclipse.org/che/getting-started. | ||
" | ||
} | ||
|
||
usage () { | ||
printf "%s" "${USAGE}" | ||
} | ||
|
||
info() { | ||
printf "${GREEN}INFO:${NC} %s\n" "${1}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. multiple spaces after printf There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trailing spaces removed |
||
} | ||
|
||
debug() { | ||
printf "${BLUE}DEBUG:${NC} %s\n" "${1}" | ||
} | ||
|
||
error() { | ||
printf "${RED}ERROR:${NC} %s\n" "${1}" | ||
} | ||
|
||
error_exit() { | ||
echo "---------------------------------------" | ||
error "!!!" | ||
error "!!! ${1}" | ||
error "!!!" | ||
echo "---------------------------------------" | ||
exit 1 | ||
} | ||
|
||
check_docker() { | ||
if ! docker ps > /dev/null 2>&1; then | ||
output=$(docker) | ||
error_exit "Error - Docker not installed properly: ${output}" | ||
fi | ||
} | ||
|
||
parse_command_line () { | ||
for command_line_option in "$@"; do | ||
case ${command_line_option} in | ||
start|stop|restart|update|info|-h|--help) | ||
CHE_CLI_ACTION=${command_line_option} | ||
;; | ||
*) | ||
# unknown option | ||
error_exit "You passed an unknown command line option." | ||
;; | ||
esac | ||
done | ||
} | ||
|
||
execute_che_launcher() { | ||
|
||
update_che_launcher | ||
|
||
info "ECLIPSE CHE: LAUNCHING LAUNCHER" | ||
docker run -it --rm --name "${CHE_LAUNCHER_CONTAINER_NAME}" \ | ||
-v //var//run//docker.sock://var//run//docker.sock \ | ||
"${CHE_LAUNCHER_IMAGE_NAME}":"${CHE_VERSION}" "${CHE_CLI_ACTION}" \ | ||
# > /dev/null 2>&1 | ||
} | ||
|
||
execute_command_with_progress() { | ||
local progress=$1 | ||
local command=$2 | ||
shift 2 | ||
|
||
local pid="" | ||
printf "\n" | ||
|
||
case "$progress" in | ||
extended) | ||
$command "$@" | ||
;; | ||
basic|*) | ||
$command "$@" &>/dev/null & | ||
pid=$! | ||
while kill -0 "$pid" >/dev/null 2>&1; do | ||
printf "#" | ||
sleep 10 | ||
done | ||
wait $pid # return pid's exit code | ||
printf "\n" | ||
;; | ||
esac | ||
printf "\n" | ||
} | ||
|
||
update_che_launcher() { | ||
if [ -z "${CHE_VERSION}" ]; then | ||
CHE_VERSION=${DEFAULT_CHE_VERSION} | ||
fi | ||
|
||
CURRENT_IMAGE=$(docker images -q ${CHE_LAUNCHER_IMAGE_NAME}:${CHE_VERSION}) | ||
|
||
if [ "${CURRENT_IMAGE}" != "" ]; then | ||
info "ECLIPSE CHE: ALREADY HAVE IMAGE ${CHE_LAUNCHER_IMAGE_NAME}:${CHE_VERSION}" | ||
else | ||
info "ECLIPSE CHE: PULLING IMAGE ${CHE_LAUNCHER_IMAGE_NAME}:${CHE_VERSION}" | ||
execute_command_with_progress extended docker pull ${CHE_LAUNCHER_IMAGE_NAME}:${CHE_VERSION} | ||
info "ECLIPSE CHE: IMAGE ${CHE_LAUNCHER_IMAGE_NAME}:${CHE_VERSION} INSTALLED" | ||
fi | ||
} | ||
|
||
# See: https://sipb.mit.edu/doc/safe-shell/ | ||
set -e | ||
set -u | ||
|
||
init_logging | ||
check_docker | ||
init_global_variables | ||
parse_command_line "$@" | ||
|
||
case ${CHE_CLI_ACTION} in | ||
start|stop|restart|update|info) | ||
execute_che_launcher | ||
;; | ||
update-cli) | ||
update_che_launcher | ||
;; | ||
help) | ||
usage | ||
;; | ||
esac |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/sh | ||
# Copyright (c) 2012-2016 Codenvy, S.A. | ||
# All rights reserved. This program and the accompanying materials | ||
# are made available under the terms of the Eclipse Public License v1.0 | ||
# which accompanies this distribution, and is available at | ||
# http://www.eclipse.org/legal/epl-v10.html | ||
# | ||
cd /che | ||
yes | cp -rf /che/files-to-install/* /che |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Copyright (c) 2012-2016 Codenvy, S.A., Red Hat, Inc. | ||
# All rights reserved. This program and the accompanying materials | ||
# are made available under the terms of the Eclipse Public License v1.0 | ||
# which accompanies this distribution, and is available at | ||
# http://www.eclipse.org/legal/epl-v10.html | ||
# | ||
# Contributors: | ||
# Codenvy, S.A. - initial API and implementation | ||
# Mario Loriedo | ||
# | ||
# To build, in this directory: | ||
# docker build -t codenvy/che-dev . | ||
# | ||
# Use it to Build Che using Docker on Linux or Mac. Run int the repository root: | ||
# docker run -it --rm --name build-che | ||
# -v "$HOME/.m2:/home/user/.m2" | ||
# -v "$PWD":/home/user/che-build | ||
# -w /home/user/che-build | ||
# codenvy/che-dev | ||
# mvn -DskipTests=true | ||
# -Dfindbugs.skip=true | ||
# -Dgwt.compiler.localWorkers=2 -T 1C | ||
# -Dskip-validate-sources | ||
# clean install | ||
# | ||
# For Windows, replace $HOME with maven repo directory. | ||
# For Windows, replace $PWD with Che source code directory. | ||
# | ||
|
||
FROM codenvy/debian_jdk8 | ||
ENV NODE_VERSION=0.12.9 \ | ||
NODE_PATH=/usr/local/lib/node_modules | ||
|
||
RUN sudo apt-get update && \ | ||
sudo apt-get -y install build-essential libssl-dev libkrb5-dev gcc make ruby-full rubygems && \ | ||
sudo gem install sass compass && \ | ||
sudo apt-get clean && \ | ||
sudo apt-get -y autoremove && \ | ||
sudo apt-get -y clean && \ | ||
sudo rm -rf /var/lib/apt/lists/* && \ | ||
set -ex \ | ||
&& for key in \ | ||
9554F04D7259F04124DE6B476D5A82AC7E37093B \ | ||
94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \ | ||
0034A06D9D9B0064CE8ADF6BF1747F4AD2306D93 \ | ||
FD3A5288F042B6850C66B31F09FE44734EB7990E \ | ||
71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \ | ||
DD8F2338BAE7501E3DD5AC78C273792F7D83545D \ | ||
; do \ | ||
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ | ||
done && \ | ||
cd /home/user && curl --insecure -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.gz" \ | ||
&& curl --insecure -SLO "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \ | ||
&& gpg --verify SHASUMS256.txt.asc \ | ||
&& grep "node-v$NODE_VERSION-linux-x64.tar.gz\$" SHASUMS256.txt.asc | sha256sum -c - \ | ||
&& sudo tar -xzf "node-v$NODE_VERSION-linux-x64.tar.gz" -C /usr/local --strip-components=1 \ | ||
&& sudo rm "node-v$NODE_VERSION-linux-x64.tar.gz" SHASUMS256.txt.asc | ||
|
||
EXPOSE 3000 5000 9000 | ||
RUN sudo npm install -g npm@latest | ||
RUN sudo npm install --unsafe-perm -g gulp bower | ||
RUN mkdir ~/gopath && \ | ||
cd /home/user && wget -q https://storage.googleapis.com/golang/go1.6.2.linux-amd64.tar.gz && \ | ||
sudo tar -xvf go1.6.2.linux-amd64.tar.gz -C /opt/ && \ | ||
rm go1.6.2.linux-amd64.tar.gz | ||
ENV GOROOT=/opt/go | ||
ENV GOPATH=/home/user/gopath | ||
RUN echo "export PATH=$GOROOT/bin:$PATH" >> ~/.bashrc && \ | ||
sudo chown -R user:user /opt | ||
WORKDIR /home/user |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It won't show if API is running. I think you have to parse respond code to be equal to 200. Trailing slash is also needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. This check only verify if host is responding or not. I've changed it to:
curl -I http://"${CHE_HOST_IP}":"${CHE_PORT}"/api/ 2>/dev/null | head -n 1 | cut -d' ' -f2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change curl command here to reflect what you've done in launcher.sh