adds Dockerfile to build immutable application image

This commit is contained in:
Sameer Naik
2017-01-17 19:56:08 +05:30
parent 69d831cf7d
commit 0a6b410660
3 changed files with 49 additions and 0 deletions

View File

@@ -81,6 +81,17 @@ add_sample_code() {
fi
}
add_dockerfile() {
if [[ ! -f Dockerfile ]]; then
cp -r /dist/Dockerfile.tpl Dockerfile
sed -i 's/{{BITNAMI_IMAGE_VERSION}}/'"$BITNAMI_IMAGE_VERSION"'/g' Dockerfile
fi
if [[ ! -f .dockerignore ]]; then
cp -r /dist/.dockerignore .
fi
}
npm_install() {
if ! [[ -n $SKIP_NPM_INSTALL && $SKIP_NPM_INSTALL -gt 0 ]] && [[ -f package.json ]] && ! dependencies_up_to_date; then
log "Installing/Updating Express dependencies (npm)"
@@ -109,6 +120,8 @@ if [ "$1" == npm ] && [ "$2" == "start" -o "$2" == "run" ]; then
add_sample_code
fi
add_dockerfile
npm_install
if ! fresh_container; then

View File

@@ -0,0 +1,5 @@
.git/
node_modules/
.gitignore
docker-compose.yml

View File

@@ -0,0 +1,31 @@
## GENERATED BY bitnami/express:{{BITNAMI_IMAGE_VERSION}} IMAGE
## BROUGHT TO YOU BY BITNAMI.
##
## BUILDING
## (from project root directory)
## $ docker build -t myapp .
##
## RUNNING
## $ docker run -p 3000:3000 myapp
##
FROM bitnami/express:{{BITNAMI_IMAGE_VERSION}}
MAINTAINER john.smith@acme.com
ENV DISABLE_WELCOME_MESSAGE=1
ENV NODE_ENV=production \
PORT=3000
# fine tune the behavior of the default entrypoint
ENV SKIP_DB_WAIT=0 \
SKIP_DB_MIGRATION=1 \
SKIP_NPM_INSTALL=1
COPY . /app
RUN sudo chown -R bitnami: /app
RUN npm install
EXPOSE 3000
CMD ["npm", "start"]