Skip to content

Instantly share code, notes, and snippets.

@ubermuda
Last active August 29, 2015 14:04
Show Gist options
  • Save ubermuda/1bf1abc3c121f5415f65 to your computer and use it in GitHub Desktop.
Save ubermuda/1bf1abc3c121f5415f65 to your computer and use it in GitHub Desktop.
Examples of using NPM in a http://stage1.io build
build:
- apt-get update -y
- apt-get install -y software-properties-common python-software-properties python g++ make
- apt-add-repository ppa:chris-lea/node.js
- apt-get update -y
- apt-get install -y nodejs
- npm install -g bower
- bower install --allow-root
- composer install --ansi --no-progress --dev --prefer-dist --no-interaction
- app/console doctrine:schema:update --force
- app/console doctrine:fixtures:load --no-interaction
- app/console assets:install web/
- app/console assetic:dump
writable:
- app/logs
- app/cache
- web/uploads

Using npm in a stage1.io build

When using a .stage1.yml configuration file, your base image will always be an ubuntu. Using npm is just a matter of installing it with, for example, the following lines:

apt-get install -y software-properties-common python-software-properties python g++ make
apt-add-repository ppa:chris-lea/node.js
apt-get update -y
apt-get install -y nodejs
npm install -g bower

If you use a Dockerfile, it depends on your base image, but the idea is the same :)

note: these examples are full-fledged examples used in production at stage1.io, they do show much more than just npm usage

FROM stackbrew/ubuntu:saucy
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update -y
RUN apt-get install -y \
daemontools curl nginx mysql-server git \
php5-cli php5-json php5-fpm php5-intl php5-mysqlnd php5-curl
RUN apt-get install -y software-properties-common python-software-properties python g++ make
RUN apt-add-repository ppa:chris-lea/node.js
RUN apt-get update -y
RUN apt-get install -y nodejs
RUN npm install -g bower
RUN curl -sS https://getcomposer.org/installer | php
RUN mv composer.phar /usr/local/bin/composer
RUN sed -e 's/;daemonize = yes/daemonize = no/' -i /etc/php5/fpm/php-fpm.conf
RUN sed -e 's/;listen\.owner/listen.owner/' -i /etc/php5/fpm/pool.d/www.conf
RUN sed -e 's/;listen\.group/listen.group/' -i /etc/php5/fpm/pool.d/www.conf
RUN echo "\ndaemon off;" >> /etc/nginx/nginx.conf
ADD docker/vhost.conf /etc/nginx/sites-enabled/default
ADD docker/php.ini /etc/php5/fpm/php.ini
ADD docker/php.ini /etc/php5/cli/php.ini
ADD docker/my.cnf /etc/mysql/my.cnf
ADD docker/service/ /srv/service
ADD . /var/www
ADD docker/parameters.yml /var/www/app/config/
WORKDIR /var/www
RUN docker/start_mysql.sh && mysqladmin create symfony
RUN bower install --allow-root
# we need to start mysql for composer install because of jms-job-queue
RUN docker/start_mysql.sh && composer install
RUN docker/start_mysql.sh && bin/reload
RUN docker/start_mysql.sh && app/console assetic:dump
RUN mkdir -p web/uploads web/avatars
RUN chmod -R 777 app/cache app/logs web/uploads web/avatars /var/lib/php5
ADD docker/entrypoint.sh /usr/local/bin/entrypoint.sh
EXPOSE 80
CMD ["/usr/local/bin/entrypoint.sh"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment