Dockerfile 4.51 KB
Newer Older
nabil el mahiri committed
1
# Stage 0, "build-stage", based on Node.js, to build and compile Angular
nabil el mahiri committed
2
FROM node:6.11.1 as build-stage
nabil el mahiri committed
3

4 5 6 7 8
# Take an SSH key build token and deploy token as a build argument.
ARG SSH_PRIVATE_KEY
ARG BUILD_TOKEN
ARG DEPLOY_TOKEN

9 10
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
    DEBIAN_FRONTEND=noninteractive apt-get -y dist-upgrade
nabil el mahiri committed
11 12

# Installing supervisord
13
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y supervisor && \
chahir committed
14 15 16 17 18
    apt-get install -y gnupg2 && \
    apt-get install -yq ssh && \
    apt-get install -yq tree && \
    apt-get install -y openssh-server && \
    apt-get install -yq redis-server
19 20

# add supervisor conf
nabil el mahiri committed
21
ADD ./docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf 
chahir committed
22

23
# install nginx
24
RUN DEBIAN_FRONTEND=noninteractive apt-get -yq install net-tools nginx lsb-release
nabil el mahiri committed
25

26 27 28
RUN rm -f /etc/nginx/fastcgi.conf /etc/nginx/fastcgi_params && \
    rm -f /etc/nginx/snippets/fastcgi-php.conf /etc/nginx/snippets/snakeoil.conf && \
    rm -f /etc/nginx/sites-available/default && \
nabil el mahiri committed
29 30
    rm -f /etc/nginx/sites-enabled/default

31
# copy nginx conf
nabil el mahiri committed
32 33 34
COPY /nginx/default.conf /etc/nginx/sites-available
COPY /nginx/default.conf /etc/nginx/sites-enabled

35
# install grunt
nabil el mahiri committed
36
RUN npm install --global grunt-cli 
nabil el mahiri committed
37

38
# install mongo version 3.4 
39 40 41 42
# 1. add mongo repo 
# 2. install mongo 
# 3. create db folder 
# 4. run mongo in background
nabil el mahiri committed
43
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6 && \  
44
    echo "deb http://repo.mongodb.org/apt/debian jessie/mongodb-org/3.4 main" | tee /etc/apt/sources.list.d/mongodb-org-3.4.list
45 46 47 48
RUN apt-get update && apt-get -yq install mongodb-org  
RUN mkdir -p /data/db 
RUN mongod --fork --syslog

nabil el mahiri committed
49

50
# install expect form automatic npm login
nabil el mahiri committed
51
RUN apt-get -yq install expect-dev
nabil el mahiri committed
52

53
# dump mongo db 
nabil el mahiri committed
54 55 56 57
# sudo ./mongodb/bin/mongodump --host localhost --port 27017 --db atlasvoyages-dev --out ./

# sudo ./mongodb/bin/mongodump --host localhost --port 27017 --db atlasvoyages-dev --gzip --archive=atlasvoyages-dev.archive

nabil el mahiri committed
58
# RUN git config --global http.proxy http://<username>:<password>@<proxy-server-url>:<port>
nabil el mahiri committed
59

60
# RUN echo "//<npm-registry>:8080/:_authToken=KB9DEBiM5vNeGPwinPuj" > ~/.npmrc
nabil el mahiri committed
61

62

nabil el mahiri committed
63
# RUN echo exit 0 > /usr/sbin/policy-rc.d
chahir committed
64

nabil el mahiri committed
65 66 67 68
# 1. Create the SSH directory.
# 2. Populate the private key file.
# 3. Set the required permissions.
# 4. Add github to our list of known hosts for ssh.
69 70 71 72 73
RUN mkdir ~/.ssh && \
    echo "$SSH_PRIVATE_KEY" >> ~/.ssh/id_rsa && \ 
    chmod 0600 ~/.ssh/id_rsa && \
    echo "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config && \ 
    touch ~/.ssh/known_hosts && ssh-keyscan -t rsa labs.atlasvoyages.com >> ~/.ssh/known_hosts && \ 
nabil el mahiri committed
74
    ssh -T git@labs.atlasvoyages.com 
chahir committed
75 76
# echo "Host labs.atlasvoyages.com"$'\n\t'"IdentityFile ~/.ssh/id_rsa" >> ~/.ssh/config

nabil el mahiri committed
77

78 79
RUN cat ~/.ssh/known_hosts 
RUN cat ~/.ssh/id_rsa
nabil el mahiri committed
80 81 82

WORKDIR /atlasvoyages

nabil el mahiri committed
83
# COPY ./sh /atlasvoyages/sh
nabil el mahiri committed
84

85
# RUN login automatiquely to npm
86
# RUN expect -f ./sh/npm_login_expect nabilelmahiri password "nabil.elmahiri@fractalite.com" 
nabil el mahiri committed
87

nabil el mahiri committed
88
COPY package*.json /atlasvoyages/
nabil el mahiri committed
89

90
# RUN include deploy token in gitlab urls in each of the modules
91
RUN sed -i 's/git+ssh:\/\/git@labs.atlasvoyages.com:/git+http:\/\/gitlab-ci-token:'$DEPLOY_TOKEN'@labs.atlasvoyages.com\//' ./package.json
nabil el mahiri committed
92

nabil el mahiri committed
93
RUN npm install --unsafe-perm=true 
nabil el mahiri committed
94

nabil el mahiri committed
95 96 97
# hide deploy token
RUN sed -i 's/git+ssh:\/\/git@labs.atlasvoyages.com:/git+http:\/\/gitlab-ci-token:xxxxxxxxx@labs.atlasvoyages.com\//' ./package.json

nabil el mahiri committed
98
COPY ./ /atlasvoyages/
nabil el mahiri committed
99

nabil el mahiri committed
100

nabil el mahiri committed
101
RUN chmod -R 700  /atlasvoyages/apps
nabil el mahiri committed
102
RUN chown -R www-data:www-data /atlasvoyages/apps
nabil el mahiri committed
103

104
# restore mongo db database
nabil el mahiri committed
105
# RUN mongorestore --host localhost --port 27017 --gzip --archive=atlasvoyages-dev.archive
nabil el mahiri committed
106

nabil el mahiri committed
107 108 109
RUN find ./node_modules -maxdepth 1 -name "pine*" -type d \( ! -name . \) -exec bash -c "cd '{}' && npm i --unsafe-perm=true && grunt build:dist --force" \; && \
    find ./node_modules -maxdepth 1 -name "hermes*" -type d \( ! -name . \) -exec bash -c "cd '{}' && npm i --unsafe-perm=true && grunt build:dist --force" \; && \
    find ./node_modules -maxdepth 1 -name "theme-atlasvoyages*" -type d \( ! -name . \) -exec bash -c "cd '{}' && npm i --unsafe-perm=true && grunt build:dist --force" \;
nabil el mahiri committed
110

chahir committed
111 112
#RUN find ./apps/atlasvoyages  -maxdepth 1 -exec bash -c "git clone http://labs.atlasvoyages.com/webapps/atlas-voyages.git && rm -rf ./public && cp " \; 
RUN echo '\n location ------' | pwd
nabil el mahiri committed
113
RUN echo '\n' | grunt pine:setup
nabil el mahiri committed
114
# RUN tree /atlasvoyages/apps/atlas-voyages/
nabil el mahiri committed
115

nabil el mahiri committed
116 117
RUN grunt pine:copy

nabil el mahiri committed
118

nabil el mahiri committed
119 120 121
# expose port 80 443
EXPOSE 80
EXPOSE 443
nabil el mahiri committed
122
EXPOSE 7778
nabil el mahiri committed
123

124
# setup endpoint for the final container
nabil el mahiri committed
125 126
ENTRYPOINT ["/usr/bin/supervisord"]