-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dockerfile
69 lines (55 loc) · 2.28 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
FROM phusion/passenger-nodejs:2.0.0
# Set correct environment variables
ENV HOME /home/app
ENV DOCKERIZE_VERSION v0.2.0
## downgrading NodeJS
ENV NVM_DIR /usr/local/nvm
ENV NODE_VERSION 0.10.46
# ENV NODE_VERSION 0.6.12 #version in the old server
ENV NODE_PATH $NVM_DIR/versions/node/v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
# Use baseimage-docker's init process
CMD ["/sbin/my_init"]
# Update installed APT packages, clean up when done
RUN apt-get update && \
apt-get upgrade -y -o Dpkg::Options::="--force-confold" && \
apt-get install wget git ntp -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Enable Passenger and Nginx and remove the default site
# Preserve env variables for nginx
RUN rm -f /etc/service/nginx/down && \
rm /etc/nginx/sites-enabled/default
COPY vendor/docker/webapp.conf /etc/nginx/sites-enabled/webapp.conf
COPY vendor/docker/00_app_env.conf /etc/nginx/conf.d/00_app_env.conf
# install dockerize
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && \
tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz
# Use Amazon NTP servers
COPY vendor/docker/ntp.conf /etc/ntp.conf
# Copy webapp folder
COPY . /home/app/webapp/
# Replace shell with bash so we can source files
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
# Set debconf to run non-interactively
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
WORKDIR /home/app/webapp/vendor
# Install nvm with node and npm
# RUN /sbin/setuser app cp nvm/bash_profile ~/.bash_profile \
RUN bash /home/app/webapp/vendor/nvm/install.sh\
&& source $NVM_DIR/nvm.sh \
&& nvm install $NODE_VERSION \
&& nvm alias default $NODE_VERSION \
&& nvm use default
RUN chown -R app:app /home/app/webapp && \
chmod -R 755 /home/app/webapp
# Install npm and bower packages
WORKDIR /home/app/webapp
RUN npm install
# Run additional scripts during container startup (i.e. not at build time)
# Process templates using ENV variables
RUN mkdir -p /etc/my_init.d
COPY vendor/docker/70_templates.sh /etc/my_init.d/70_templates.sh
COPY vendor/docker/80_submodules.sh /etc/my_init.d/80_submodules.sh
# Expose web
EXPOSE 80