forked from openstf/stf
-
Notifications
You must be signed in to change notification settings - Fork 492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updating gulp, webpack, and Dockerfile #118
Open
nanoscopic
wants to merge
15
commits into
DeviceFarmer:master
Choose a base branch
from
nanoscopic:to_upstream
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
44668dc
Updating gulp, webpack, and Dockerfile
nanoscopic 2a99631
Continuing to get updated build/frontend working
nanoscopic 56fc25c
Many fixes for updated build
nanoscopic 6343c0e
Get updated modules working
nanoscopic 3578b04
Random small fixes. Added IPA install support.
nanoscopic 87992be
Alert response functionality
nanoscopic 083cfd1
Remove babelrc copy breaking Docker image build
nanoscopic a16ed64
Fix mousewheel
nanoscopic 87d7a36
Bump then-jade from 2.4.3 to 2.4.4 (#115)
dependabot-preview[bot] 582d38f
Bump imports-loader from 0.6.5 to 0.8.0 (#117)
dependabot-preview[bot] 3206e32
Bump rethinkdb from 2.3.3 to 2.4.2 (#116)
dependabot-preview[bot] f4ae304
Merge branch 'master' into upstream
nanoscopic 6c463c5
Merge pull request #1 from nanoscopic/upstream
nanoscopic be1552a
Re-add .aab installation support
d111d60
Merge branch 'master' into to_upstream
nanoscopic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
{ | ||
"registry": "https://registry.bower.io", | ||
"directory": "res/bower_components" | ||
"registry": "http://registry.bower.io", | ||
"directory": "/tmp/build/bower_modules", | ||
"allow_root": true, | ||
"off_proxy": "http://127.0.0.1:8080", | ||
"off_https-proxy": "http://127.0.0.1:8080", | ||
"strict-ssl": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ rethinkdb_data/ | |
temp/ | ||
tmp/ | ||
.eslintcache | ||
Dockerfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,117 @@ | ||
FROM ubuntu:16.04 | ||
FROM ubuntu:18.04 AS nodebase | ||
|
||
# Sneak the stf executable into $PATH. | ||
ENV PATH /app/bin:$PATH | ||
# Install base packages | ||
RUN export DEBIAN_FRONTEND=noninteractive && \ | ||
apt-get update && \ | ||
apt-get -y --no-install-recommends install curl wget libxml-bare-perl libzmq3-dev libprotobuf-dev graphicsmagick ca-certificates openjdk-8-jdk | ||
|
||
# Work in app dir by default. | ||
WORKDIR /app | ||
# Install node | ||
RUN export DEBIAN_FRONTEND=noninteractive && \ | ||
curl -sL -o /tmp/install_node.sh https://deb.nodesource.com/setup_8.x && \ | ||
/bin/bash /tmp/install_node.sh && \ | ||
apt install --no-install-recommends -y nodejs | ||
|
||
# Export default app port, not enough for all processes but it should do | ||
# for now. | ||
EXPOSE 3000 | ||
RUN useradd --system --create-home --shell /usr/sbin/nologin stf | ||
|
||
FROM nodebase as with_packages | ||
|
||
# Install app requirements. Trying to optimize push speed for dependant apps | ||
# by reducing layers as much as possible. Note that one of the final steps | ||
# installs development files for node-gyp so that npm install won't have to | ||
# wait for them on the first native module installation. | ||
# Install additional packages for building things | ||
RUN export DEBIAN_FRONTEND=noninteractive && \ | ||
useradd --system \ | ||
--create-home \ | ||
--shell /usr/sbin/nologin \ | ||
stf-build && \ | ||
useradd --system \ | ||
--create-home \ | ||
--shell /usr/sbin/nologin \ | ||
stf && \ | ||
sed -i'' 's@http://archive.ubuntu.com/ubuntu/@mirror://mirrors.ubuntu.com/mirrors.txt@' /etc/apt/sources.list && \ | ||
apt-get update && \ | ||
apt-get -y install wget python build-essential && \ | ||
cd /tmp && \ | ||
wget --progress=dot:mega \ | ||
https://nodejs.org/dist/v8.9.3/node-v8.9.3-linux-x64.tar.xz && \ | ||
tar -xJf node-v*.tar.xz --strip-components 1 -C /usr/local && \ | ||
rm node-v*.tar.xz && \ | ||
su stf-build -s /bin/bash -c '/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js install' && \ | ||
apt-get -y install libzmq3-dev libprotobuf-dev git graphicsmagick openjdk-8-jdk yasm && \ | ||
apt-get clean && \ | ||
rm -rf /var/cache/apt/* /var/lib/apt/lists/* && \ | ||
mkdir /tmp/bundletool && \ | ||
cd /tmp/bundletool && \ | ||
wget --progress=dot:mega \ | ||
https://github.com/google/bundletool/releases/download/1.2.0/bundletool-all-1.2.0.jar && \ | ||
mv bundletool-all-1.2.0.jar bundletool.jar | ||
|
||
# Copy app source. | ||
COPY . /tmp/build/ | ||
|
||
# Give permissions to our build user. | ||
RUN mkdir -p /app && \ | ||
chown -R stf-build:stf-build /tmp/build /tmp/bundletool /app | ||
|
||
# Switch over to the build user. | ||
USER stf-build | ||
|
||
# Run the build. | ||
apt-get -y --no-install-recommends install build-essential git yasm jq python vim | ||
|
||
# Install node-gyp ahead of time to avoid installation on native module install | ||
# RUN /bin/bash -c '/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js install' | ||
|
||
# Install just the package dependencies before copying in the full source | ||
RUN mkdir -p /tmp/build/res/build | ||
COPY ./package*.json /tmp/build/ | ||
WORKDIR /tmp/build | ||
RUN set -x && \ | ||
cd /tmp/build && \ | ||
export PATH=$PWD/node_modules/.bin:$PATH && \ | ||
npm install --loglevel http && \ | ||
npm pack && \ | ||
tar xzf devicefarmer-stf-*.tgz --strip-components 1 -C /app && \ | ||
bower cache clean && \ | ||
npm prune --production && \ | ||
mv node_modules /app && \ | ||
rm -rf ~/.node-gyp && \ | ||
mkdir /app/bundletool && \ | ||
mv /tmp/bundletool/* /app/bundletool && \ | ||
cd /app && \ | ||
find /tmp -mindepth 1 ! -regex '^/tmp/hsperfdata_root\(/.*\)?' -delete | ||
|
||
# Switch to the app user. | ||
USER stf | ||
curl -sf https://gobinaries.com/tj/node-prune | sh | ||
|
||
wget --progress=dot:mega \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
https://github.com/google/bundletool/releases/download/1.2.0/bundletool-all-1.2.0.jar \ | ||
-O /tmp/bundletool.jar | ||
|
||
# ********* FRONTEND ********** | ||
|
||
FROM with_packages as frontend | ||
|
||
# Install bower dependencies | ||
WORKDIR /tmp/build | ||
COPY ./bower.json /tmp/build/ | ||
COPY ./.bowerrc /tmp/build/ | ||
RUN mkdir bower_modules && \ | ||
./node_modules/.bin/bower install | ||
|
||
# Copy the app ( res ) in | ||
COPY ./bower.json /tmp/build/ | ||
COPY ./gulpfile.js /tmp/build/ | ||
COPY ./webpack.config.js /tmp/build/ | ||
COPY ./res /tmp/build/res | ||
COPY ./lib/util /tmp/build/lib/util | ||
|
||
RUN ./node_modules/.bin/gulp build | ||
|
||
# ********* BACKEND ********** | ||
|
||
FROM with_packages as backend | ||
|
||
COPY ./lib /tmp/build/lib | ||
|
||
# Package and cleanup | ||
WORKDIR /tmp/build | ||
RUN npm pack 2>&1 | grep -v "npm notice [1-9]" && \ | ||
mv devicefarmer-stf-$(jq .version package.json -j).tgz stf.tgz | ||
|
||
#npm prune --production && \ | ||
# node-prune && \ | ||
|
||
FROM alpine as app | ||
|
||
RUN mkdir -p /app | ||
COPY --from=backend /tmp/build/stf.tgz /tmp/stf.tgz | ||
RUN tar xf /tmp/stf.tgz --strip-components 1 -C /app | ||
|
||
# ********* RUNTIME ********** | ||
|
||
FROM nodebase as runtime | ||
|
||
EXPOSE 3000 | ||
|
||
# Setup user | ||
RUN mkdir -p /app/res && mkdir -p /app/bundletool && chown stf:stf /app && chown stf:stf /app/* | ||
|
||
WORKDIR /app | ||
|
||
# Copy in node_modules and prune them | ||
COPY --from=with_packages --chown=stf:stf /tmp/build/node_modules /app/node_modules | ||
COPY --from=with_packages --chown=stf:stf /tmp/build/package.json /app/package.json | ||
RUN npm prune --production | ||
|
||
# Copy in resources needed by backend | ||
COPY --chown=stf:stf ./res/common /app/res/common | ||
COPY --chown=stf:stf ./res/app/views /app/res/app/views | ||
COPY --chown=stf:stf ./res/auth/mock/views /app/res/auth/mock/views | ||
|
||
# Copy in the backend | ||
COPY --from=app --chown=stf:stf /app /app | ||
|
||
# Copy in the frontend | ||
COPY --from=frontend --chown=stf:stf /tmp/build/res/build /app/res/build | ||
|
||
# Copy in bundletool | ||
COPY --from=with_packages --chown=stf:stf /tmp/bundletool.jar /app/bundletool/bundletool.jar | ||
|
||
COPY ./webpackserver.config.js /app/ | ||
|
||
#USER root | ||
#RUN apt-get -y --no-install-recommends install ncdu | ||
|
||
# Add stf executable dir into $PATH | ||
ENV PATH /app/bin:$PATH | ||
|
||
# Show help by default. | ||
CMD stf --help |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if there is an explanation in the commit message, I'd rather not keep it that way.