Skip to content

Commit

Permalink
Merge pull request #140 from mfojtik/update_create
Browse files Browse the repository at this point in the history
Merged by openshift-bot
  • Loading branch information
OpenShift Bot committed Feb 20, 2015
2 parents 28daf66 + b579cfd commit ad5adc0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 59 deletions.
44 changes: 9 additions & 35 deletions pkg/create/templates/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,18 @@ package templates

const Dockerfile = `
# {{.ImageName}}
FROM centos:centos7
FROM openshift/base-centos7
# TODO: Install required packages:
#
# RUN yum install -y --enablerepo=centosplus epel-release <packages>
ENV STI_NODEJS_VERSION 0.10
# TODO: Install required packages here:
# RUN yum install -y ... ; yum clean all -y
# Add STI usage script
ADD ./.sti/bin/usage /usage
USER default
# You can add any other required files/configurations here
# ADD conf /app-root/conf
# TODO (optional): Copy the builder files into /opt/openshift
# COPY ./<builder_folder>/ /opt/openshift/
# TODO: Define the URL from where the default STI script will be fetched:
#
# ENV STI_SCRIPTS_URL https://raw.githubusercontent.com/<repository>/master/.sti/bin
# Default destination of scripts and sources, this is where assemble will look for them
ENV STI_LOCATION /tmp
# TODO: Create the application runtime user account and app-root directory:
RUN mkdir -p /app-root/src && \
groupadd -r appuser -f -g 433 && \
useradd -u 431 -r -g appuser -d /app-root -s /sbin/nologin -c "Application user" appuser && \
chown -R appuser:appuser /app-root
# TODO: Specify the application root folder (if other than root folder), application user
# and working directory.
#
ENV APP_ROOT .
ENV HOME /app-root
ENV PATH $HOME/bin:$PATH
WORKDIR /app-root/src
USER appuser
# TODO: Specify the default port your application is running on
EXPOSE 8080
CMD ["/usage"]
# TODO: Set the default port for applications built using this image
# EXPOSE 3000
`
29 changes: 6 additions & 23 deletions pkg/create/templates/scripts.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,25 @@ const AssembleScript = `
# https://github.com/openshift/source-to-image/blob/master/docs/builder_image.md
#
# The $HOME variable points to the application root
HOME=${HOME-"/app-root"}
# The application sources are mounted during the STI build into /tmp/src
APP_SRC_DIR="/tmp/src"
# The directory where the sources should be installed
APP_RUNTIME_DIR="${HOME}/src"
# Display assemble script usage
#
if [ "$1" = "-h" ]; then
# If the '{{.ImageName}}' assemble script is executed with '-h' flag,
# print the usage.
exit 0
exec /usr/local/sti/usage
fi
# Restore artifacts from the previous build (if exists).
#
if [ "$(ls /tmp/artifacts/ 2>/dev/null)" ]; then
echo "Restoring build artifacts"
mv /tmp/artifacts/* $HOME/.
echo "---> Restoring build artifacts"
mv /tmp/artifacts/* ./
fi
echo "---> Installing application source"
mkdir -p ${APP_RUNTIME_DIR}
cp -Rf ${APP_SRC_DIR}/* ${APP_RUNTIME_DIR}/
cp -Rf /tmp/src/* ./
pushd "$APP_RUNTIME_DIR/${APP_ROOT}" >/dev/null
echo "---> Building application from source"
# TODO: Add build steps for your application
popd >/dev/null
# TODO: Add build steps for your application, for example npm install or
# bundle install, etc...
`

const RunScript = `
Expand All @@ -53,9 +40,7 @@ const RunScript = `
# For more informations see the documentation:
# https://github.com/openshift/source-to-image/blob/master/docs/builder_image.md
#
APP_ROOT_DIR="${HOME}/src/${APP_ROOT:-.}"
cd $APP_ROOT_DIR
exec <start your server here>
`

Expand Down Expand Up @@ -85,7 +70,5 @@ const SaveArtifactsScript = `
# For more informations see the documentation:
# https://github.com/openshift/source-to-image/blob/master/docs/builder_image.md
#
pushd ${HOME} >/dev/null
# tar cf - <list of files and folders>
popd >/dev/null
`
1 change: 0 additions & 1 deletion pkg/create/templates/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,4 @@ build:
test:
docker build -t $(IMAGE_NAME)-candidate .
IMAGE_NAME=$(IMAGE_NAME)-candidate test/run
`

0 comments on commit ad5adc0

Please sign in to comment.