From 7a9d316a206bd063e74079097d131fd48433f19b Mon Sep 17 00:00:00 2001 From: Bitnami Bot Date: Mon, 9 Jul 2018 13:47:08 +0000 Subject: [PATCH] 4.16.3-debian-9-r0 release Add Oracle Linux support --- bitnami/express/4/debian-9/Dockerfile | 24 +++ bitnami/express/4/debian-9/docker-compose.yml | 25 +++ .../4/debian-9/rootfs/app-entrypoint.sh | 39 +++++ .../4/debian-9/rootfs/dist/.dockerignore | 4 + .../express/4/debian-9/rootfs/dist/.gitignore | 1 + .../4/debian-9/rootfs/dist/Dockerfile.tpl | 23 +++ .../4/debian-9/rootfs/dist/samples/mariadb.js | 19 +++ .../4/debian-9/rootfs/dist/samples/mongodb.js | 20 +++ .../rootfs/opt/bitnami/express/functions | 149 ++++++++++++++++++ bitnami/express/README.md | 2 +- 10 files changed, 305 insertions(+), 1 deletion(-) create mode 100644 bitnami/express/4/debian-9/Dockerfile create mode 100644 bitnami/express/4/debian-9/docker-compose.yml create mode 100755 bitnami/express/4/debian-9/rootfs/app-entrypoint.sh create mode 100644 bitnami/express/4/debian-9/rootfs/dist/.dockerignore create mode 100644 bitnami/express/4/debian-9/rootfs/dist/.gitignore create mode 100644 bitnami/express/4/debian-9/rootfs/dist/Dockerfile.tpl create mode 100644 bitnami/express/4/debian-9/rootfs/dist/samples/mariadb.js create mode 100644 bitnami/express/4/debian-9/rootfs/dist/samples/mongodb.js create mode 100644 bitnami/express/4/debian-9/rootfs/opt/bitnami/express/functions diff --git a/bitnami/express/4/debian-9/Dockerfile b/bitnami/express/4/debian-9/Dockerfile new file mode 100644 index 000000000000..e161d9c0a19f --- /dev/null +++ b/bitnami/express/4/debian-9/Dockerfile @@ -0,0 +1,24 @@ +FROM bitnami/minideb-extras:stretch-r71 +LABEL maintainer "Bitnami " + +ENV BITNAMI_PKG_CHMOD="-R g+rwX" \ + HOME="/" + +# Install required system packages and dependencies +RUN install_packages ghostscript imagemagick libbz2-1.0 libc6 libgcc1 libncurses5 libreadline7 libsqlite3-0 libssl1.1 libstdc++6 libtinfo5 zlib1g +RUN bitnami-pkg install node-7.10.1-1 --checksum 53362288e961d298a724353710a31901d4cb8237894a26a2f676b35450c02975 +RUN bitnami-pkg install express-generator-4.16.0-0 --checksum 713814e0b5a01f398c32f7caaa007c661d28dffc093133decdbdb360433a8742 +RUN bitnami-pkg install express-4.16.3-1 --checksum 90fae7f6ed904c6a7b0cfe6998456cf4724696ce7dfb46f6777b3df4d594702d +RUN mkdir -p /dist /app /.npm && chmod g+rwx /app /dist /.npm + +COPY rootfs / +ENV BITNAMI_APP_NAME="express" \ + BITNAMI_IMAGE_VERSION="4.16.3-debian-9-r0" \ + PATH="/opt/bitnami/node/bin:/opt/bitnami/express/bin:$PATH" + +EXPOSE 3000 + +WORKDIR /app +USER 1001 +ENTRYPOINT ["/app-entrypoint.sh"] +CMD ["npm","start"] diff --git a/bitnami/express/4/debian-9/docker-compose.yml b/bitnami/express/4/debian-9/docker-compose.yml new file mode 100644 index 000000000000..ca128cf771af --- /dev/null +++ b/bitnami/express/4/debian-9/docker-compose.yml @@ -0,0 +1,25 @@ +version: '2' + +services: + mongodb: + image: 'bitnami/mongodb:latest' + + express: + tty: true # Enables debugging capabilities when attached to this container. + image: 'bitnami/express:4' + command: npm start + environment: + - PORT=3000 + - NODE_ENV=development + - DATABASE_URL=mongodb://mongodb:27017/myapp + + - SKIP_DB_WAIT=0 + - SKIP_DB_MIGRATION=0 + - SKIP_NPM_INSTALL=0 + - SKIP_BOWER_INSTALL=0 + depends_on: + - mongodb + ports: + - 3000:3000 + volumes: + - .:/app diff --git a/bitnami/express/4/debian-9/rootfs/app-entrypoint.sh b/bitnami/express/4/debian-9/rootfs/app-entrypoint.sh new file mode 100755 index 000000000000..162e58276a5c --- /dev/null +++ b/bitnami/express/4/debian-9/rootfs/app-entrypoint.sh @@ -0,0 +1,39 @@ +#!/bin/bash -e + +. /opt/bitnami/base/functions +. /opt/bitnami/base/helpers + +print_welcome_page + +. /opt/bitnami/express/functions + +if [ "$1" == npm ] && [ "$2" == "start" -o "$2" == "run" ]; then + bootstrap_express_app + + add_dockerfile + + install_packages + + wait_for_db + + if ! fresh_container; then + echo "#########################################################################" + echo " " + echo " App initialization skipped:" + echo " Delete the file $INIT_SEM and restart the container to reinitialize" + echo " You can alternatively run specific commands using docker-compose exec" + echo " e.g docker-compose exec myapp npm install angular" + echo " " + echo "#########################################################################" + else + # Perform any app initialization tasks here. + log "Initialization finished" + fi + + migrate_db + + touch $INIT_SEM +fi + + +exec tini -- "$@" diff --git a/bitnami/express/4/debian-9/rootfs/dist/.dockerignore b/bitnami/express/4/debian-9/rootfs/dist/.dockerignore new file mode 100644 index 000000000000..68a40097b508 --- /dev/null +++ b/bitnami/express/4/debian-9/rootfs/dist/.dockerignore @@ -0,0 +1,4 @@ +.git/ +node_modules/ +.gitignore +docker-compose.yml diff --git a/bitnami/express/4/debian-9/rootfs/dist/.gitignore b/bitnami/express/4/debian-9/rootfs/dist/.gitignore new file mode 100644 index 000000000000..c2658d7d1b31 --- /dev/null +++ b/bitnami/express/4/debian-9/rootfs/dist/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/bitnami/express/4/debian-9/rootfs/dist/Dockerfile.tpl b/bitnami/express/4/debian-9/rootfs/dist/Dockerfile.tpl new file mode 100644 index 000000000000..24a8ac7d61aa --- /dev/null +++ b/bitnami/express/4/debian-9/rootfs/dist/Dockerfile.tpl @@ -0,0 +1,23 @@ +## Dockerfile for building production image +FROM bitnami/express:{{BITNAMI_IMAGE_VERSION}} +LABEL maintainer "John Smith " + +ENV DISABLE_WELCOME_MESSAGE=1 + +ENV NODE_ENV=production \ + PORT=3000 + +# Skip fetching dependencies and database migrations for production image +ENV SKIP_DB_WAIT=0 \ + SKIP_DB_MIGRATION=1 \ + SKIP_NPM_INSTALL=1 \ + SKIP_BOWER_INSTALL=1 + +COPY . /app +RUN sudo chown -R bitnami: /app + +RUN npm install +RUN bower install + +EXPOSE 3000 +CMD ["npm", "start"] diff --git a/bitnami/express/4/debian-9/rootfs/dist/samples/mariadb.js b/bitnami/express/4/debian-9/rootfs/dist/samples/mariadb.js new file mode 100644 index 000000000000..f92729774cae --- /dev/null +++ b/bitnami/express/4/debian-9/rootfs/dist/samples/mariadb.js @@ -0,0 +1,19 @@ +/* + Note: Generated by Bitnami: + Configuration file that shows how to use the built in MySQL database in your project. + Based on the examples found here: https://github.com/mysqljs/mysql +*/ + +var mysql = require('mysql') + , assert = require('assert');; + +// Connection URL configured in your docker-compose.yml file +var url = process.env.DATABASE_URL; + +var connection = mysql.createConnection(url); +connection.connect(function(err) { + assert.equal(null, err); + console.log("Connected correctly to MySQL server"); + connection.query('SHOW TABLES;'); + connection.end(); +}); diff --git a/bitnami/express/4/debian-9/rootfs/dist/samples/mongodb.js b/bitnami/express/4/debian-9/rootfs/dist/samples/mongodb.js new file mode 100644 index 000000000000..ad668e76ec86 --- /dev/null +++ b/bitnami/express/4/debian-9/rootfs/dist/samples/mongodb.js @@ -0,0 +1,20 @@ +/* + Note: Generated by Bitnami: + Configuration file that shows how to use the built in MongoDB database in your project. + Based on the examples found here: https://github.com/mongodb/node-mongodb-native + + If you want to use an ODM instead of barebone Node connections, you can install Mongoose + https://www.npmjs.com/package/mongoose +*/ + +var MongoClient = require('mongodb').MongoClient + , assert = require('assert'); + +// Connection URL configured in your docker-compose.yml file +var url = process.env.DATABASE_URL; + +MongoClient.connect(url, function(err, db) { + assert.equal(null, err); + console.log("Connected correctly to MongoDB server"); + db.close(); +}); diff --git a/bitnami/express/4/debian-9/rootfs/opt/bitnami/express/functions b/bitnami/express/4/debian-9/rootfs/opt/bitnami/express/functions new file mode 100644 index 000000000000..d89e97bd0183 --- /dev/null +++ b/bitnami/express/4/debian-9/rootfs/opt/bitnami/express/functions @@ -0,0 +1,149 @@ +#!/bin/bash +. /opt/bitnami/base/functions + +INIT_SEM=/tmp/initialized.sem +PACKAGE_FILE=/app/package.json + +fresh_container() { + [ ! -f $INIT_SEM ] +} + +app_present() { + [ -f package.json ] +} + +dependencies_up_to_date() { + # It it up to date if the package file is older than + # the last time the container was initialized + [ ! $PACKAGE_FILE -nt $INIT_SEM ] +} + +database_tier_exists() { + [ -n "$(getent hosts mongodb mysql mariadb postgresql)" ] +} + +__wait_for_db() { + local host=$1 + local port=$2 + local ip_address=$(getent hosts $1 | awk '{ print $1 }') + + info "Connecting to at $host server at $ip_address:$port." + + counter=0 + until nc -z $ip_address $port; do + counter=$((counter+1)) + if [ $counter == 10 ]; then + error "Couldn't connect to $host server." + return 1 + fi + info "Trying to connect to $host server at $ip_address:$port. Attempt $counter." + sleep 5 + done + info "Connected to $host server." +} + +wait_for_db() { + if ! [[ -n $SKIP_DB_WAIT && $SKIP_DB_WAIT -gt 0 ]] && database_tier_exists ; then + if getent hosts mongodb >/dev/null; then + __wait_for_db mongodb 27017 + fi + + if getent hosts mariadb >/dev/null; then + __wait_for_db mariadb 3306 + fi + + if getent hosts mysql >/dev/null; then + __wait_for_db mysql 3306 + fi + + if getent hosts postgresql >/dev/null; then + __wait_for_db postgresql 5432 + fi + fi +} + +add_gitignore_sample() { + info "Installing git ignore rules." + cp /dist/.gitignore .gitignore +} + +add_sample_code() { + if ! [[ -n $SKIP_SAMPLE_CODE && $SKIP_SAMPLE_CODE -gt 0 ]]; then + info "Adding dist samples." + cp -r /dist/samples . + fi +} + +add_database_support() { + if database_tier_exists; then + if getent hosts mongodb >/dev/null && ! npm ls mongodb >/dev/null; then + info "Adding mongodb npm module." + npm install --save mongodb + fi + + if getent hosts mariadb >/dev/null && ! npm ls mysql >/dev/null || getent hosts mysql >/dev/null && ! npm ls mysql >/dev/null; then + info "Adding mysql npm module." + npm install --save mysql + fi + + if getent hosts postgresql >/dev/null && ! npm ls pg pg-hstore >/dev/null; then + info "Adding pg pg-hstore npm modules." + npm install --save pg pg-hstore + fi + fi +} + +add_nodemon_support() { + info "Adding nodemon npm module (dev)." + npm install nodemon --save-dev + sed -i 's;"start".*;"start": "node ./bin/www", "development": "nodemon ./bin/www";' package.json +} + +bootstrap_express_app() { + if ! app_present; then + info "Creating express application." + express . -f + mkdir -p tmp + mkdir -p logs + chmod og+rw -R tmp logs + add_gitignore_sample + add_database_support + add_nodemon_support + add_sample_code + else + info "Skipping creation of new application. Already exists!" + fi +} + +add_dockerfile() { + if [[ ! -f Dockerfile ]]; then + cp -r /dist/Dockerfile.tpl Dockerfile + sed -i 's/{{BITNAMI_IMAGE_VERSION}}/'"$BITNAMI_IMAGE_VERSION"'/g' Dockerfile + [[ ! -f bower.json ]] && sed -i '/^RUN bower install/d' Dockerfile + fi + + if [[ ! -f .dockerignore ]]; then + cp -r /dist/.dockerignore . + fi +} + +install_packages() { + if ! dependencies_up_to_date; then + if ! [[ -n $SKIP_NPM_INSTALL && $SKIP_NPM_INSTALL -gt 0 ]] && [[ -f package.json ]]; then + info "Installing npm packages." + npm install + fi + + if ! [[ -n $SKIP_BOWER_INSTALL && $SKIP_BOWER_INSTALL -gt 0 ]] && [[ -f bower.json ]]; then + info "Installing bower packages." + bower install + fi + fi +} + +migrate_db() { + if ! [[ -n $SKIP_DB_MIGRATE && $SKIP_DB_MIGRATE -gt 0 ]] && [[ -f .sequelizerc ]]; then + info "Applying database migrations (sequelize db:migrate)." + sequelize db:migrate + fi +} diff --git a/bitnami/express/README.md b/bitnami/express/README.md index 0911c9e881d0..3716691082c5 100644 --- a/bitnami/express/README.md +++ b/bitnami/express/README.md @@ -23,8 +23,8 @@ $ docker-compose up # Supported tags and respective `Dockerfile` links * [`4-ol-7`, `4.16.3-ol-7-r8` (4/ol-7/Dockerfile)](https://github.com/bitnami/bitnami-docker-codiad/blob/4.16.3-ol-7-r8/4/ol-7/Dockerfile) +* [`4-debian-9`, `4.16.3-debian-9-r0` (4/debian-9/Dockerfile)](https://github.com/bitnami/bitnami-docker-codiad/blob/4.16.3-debian-9-r0/4/debian-9/Dockerfile) * [`4-debian-8`, `4.16.3-debian-8-r0`, `4`, `4.16.3`, `4.16.3-r0`, `latest` (4/Dockerfile)](https://github.com/bitnami/bitnami-docker-codiad/blob/4.16.3-debian-8-r0/4/Dockerfile) -* [`4-debian-9`, `0.0.0-debian-9-r0` (4/debian-9/Dockerfile)](https://github.com/bitnami/bitnami-docker-codiad/blob/0.0.0-debian-9-r0/4/debian-9/Dockerfile) Subscribe to project updates by watching the [bitnami/codiad GitHub repo](https://github.com/bitnami/bitnami-docker-codiad).