Skip to content

Commit

Permalink
feat(docker): add initila docker files & setup for the cli
Browse files Browse the repository at this point in the history
  • Loading branch information
shahabganji authored and 3cp committed Sep 12, 2019
1 parent 8a4ceeb commit 9ea4c54
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 2 deletions.
11 changes: 11 additions & 0 deletions lib/workflow/questionnaire.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ exports.pickPlugin = {
choices: [{value: 'plugin'}]
};

exports.askDocker = {
message: 'Do you like to add a Dockerfile?' ,
choices:[{
value: 'docker' , message: 'Sure, yes'
},
{
value: 'none' , message: 'No'
}
]
};

exports.askBundler = {
message: 'Which bundler would you like to use?',
choices: [{
Expand Down
6 changes: 4 additions & 2 deletions lib/workflow/select-features.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const {
askIntegrationTestRunner,
askEditor,
askScaffold,
askPluginScaffold
askPluginScaffold,
askDocker
} = require('./questionnaire');

// Select features
Expand Down Expand Up @@ -123,7 +124,8 @@ async function appFlow(features, unattended, _debug) {
askUnitTestRunner,
askIntegrationTestRunner,
askEditor,
askScaffold
askScaffold,
askDocker
], unattended, _debug);
}

Expand Down
96 changes: 96 additions & 0 deletions skeleton/common/Dockerfile__if_docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# build stage
FROM node:12 as build

RUN npm install -g aurelia-cli

// @if feat.cypress || feat.protractor || feat.karma
ENV DEBIAN_FRONTEND=noninteractive

#update apt-get
RUN apt-get update

RUN apt-get install -y \
apt-utils \
fonts-liberation \
libappindicator3-1 \
libatk-bridge2.0-0 \
libatspi2.0-0 \
libgtk-3-0 \
libnspr4 \
libnss3 \
libx11-xcb1 \
libxtst6 \
lsb-release \
xdg-utils \
libgtk2.0-0 \
libnotify-dev \
libgconf-2-4 \
libnss3 \
libxss1 \
libasound2 \
xvfb

# cypress dependencies or use cypress/base images
RUN apt-get install -y \
libgtk2.0-0 \
libnotify-dev \
libgconf-2-4 \
libnss3 \
libxss1 \
libasound2 \
xvfb

# install chrome
RUN curl --silent --show-error --location --fail --retry 3 --output /tmp/google-chrome-stable_current_amd64.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
&& ( dpkg -i /tmp/google-chrome-stable_current_amd64.deb || apt-get -fy install) \
&& rm -rf /tmp/google-chrome-stable_current_amd64.deb \
&& sed -i 's|HERE/chrome"|HERE/chrome" --disable-setuid-sandbox --no-sandbox|g' \
"/opt/google/chrome/google-chrome" \
&& google-chrome --version

// @endif

WORKDIR /app

# install dependencies
COPY ./*.json ./
RUN npm install

# copy other files
COPY ./*.config.js ./
COPY ./*.ejs ./
COPY ./*.ico ./
COPY aurelia_project ./aurelia_project

# COPY application
COPY types ./types
COPY static ./static
COPY src ./src

// @if feat.cypress || feat.protractor || feat.jest || feat.karma
COPY test ./test
// @endif

// @if feat.jest || feat.karma
# RUN UNIT TESTS
RUN au test
// @endif

// @if feat.cypress || feat.protractor
# RUN E2E TESTS
RUN npm run e2e:headless
// @endif


# build
FROM build as publish
RUN au build

# run-time stage
FROM nginx:alpine as run-time
COPY nginx.conf /etc/nginx/nginx.conf
WORKDIR /usr/share/nginx/html
COPY --from=publish /app/dist/ .
EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]
25 changes: 25 additions & 0 deletions skeleton/common/nginx.conf__if_docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
worker_processes 1;

events {
worker_connections 1024;
}

http {
server {
listen 80;
server_name localhost;

root /usr/share/nginx/html;
index index.html index.htm;
include /etc/nginx/mime.types;

gzip on;
gzip_min_length 1000;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;

location / {
try_files $uri $uri/ /index.html;
}
}
}

0 comments on commit 9ea4c54

Please sign in to comment.