Skip to content

Instantly share code, notes, and snippets.

@rafaelrinaldi
Created August 22, 2016 17:05
Show Gist options
  • Save rafaelrinaldi/b915345cfd958ba3e3fafa6024e3e8b3 to your computer and use it in GitHub Desktop.
Save rafaelrinaldi/b915345cfd958ba3e3fafa6024e3e8b3 to your computer and use it in GitHub Desktop.
builder:
command: ['/tmp/run-no-version.sh']
environment:
BUILD_NUMBER: $BUILD_NUMBER
server:
build: .
dockerfile: ./docker/Dockerfile-server
ports:
- '8080:80'
volumes_from:
- builder
builder:
build: .
dockerfile: ./docker/Dockerfile-ui
environment:
BUILD_NUMBER: $BUILD_NUMBER
volumes:
- .:/workdir
FROM nginx
MAINTAINER Rafael Rinaldi <rinaldi@work.co>
# Copy custom configuration file from the current directory
COPY nginx/nginx.conf /etc/nginx/nginx.conf
COPY nginx/mime.types /etc/nginx/mime.types
COPY nginx/.htpasswd /etc/nginx/.htpasswd
FROM ubuntu:wily
ENV NPM_CONFIG_LOGLEVEL info
ENV NODE_VERSION 4.2.1
RUN apt-get -y update && apt-get install -y curl
RUN curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.gz" \
&& tar -xzf "node-v$NODE_VERSION-linux-x64.tar.gz" -C /usr/local --strip-components=1 \
&& rm "node-v$NODE_VERSION-linux-x64.tar.gz"
MAINTAINER Rafael Rinaldi <rafael.rinaldi@work.co>
RUN npm i npm@3.7.1 -g
# Cache node modules
ADD package.json /tmp/package.json
ADD npm-shrinkwrap.json /tmp/npm-shrinkwrap.json
# Fresh install of node modules
RUN cd /tmp && npm i
RUN mkdir /workdir
RUN cp -a /tmp/node_modules /workdir
# Mount working directory
VOLUME /workdir
WORKDIR /workdir
# Copy custom scripts
COPY ./docker/scripts/ /tmp
# Set permissions
RUN cd /tmp && chmod 755 -R /tmp/ && ls -ltra
# Finally run the command
CMD /tmp/run.sh
#!/bin/bash -xe
mkdir -p ../public
cp -a /tmp/node_modules .
npm i || cat npm-debug.log
npm run build || cat npm-debug.log
.
├── CONTRIBUTING.md
├── docker
│   ├── Dockerfile-server
│   ├── Dockerfile-ui
│   └── scripts
├── docker-compose.qa.yml
├── docker-compose.yml
├── nginx
│   ├── mime.types
│   └── nginx.conf
├── npm-shrinkwrap.json
├── package.json
├── public
│   ├── bundle.ffb4a995ec90480919c5.css
│   ├── bundle.ffb4a995ec90480919c5.js
│   └── index.html
└── webpack.config.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment