|
1 | 1 | # Base stage with common dependencies |
2 | | -FROM node:14.21.3-bullseye AS base |
| 2 | +FROM node:18.19.0-bullseye AS base |
| 3 | + |
| 4 | +# Set environment variables for better npm performance |
| 5 | +ENV NODE_ENV=production |
| 6 | +ENV NPM_CONFIG_LOGLEVEL=verbose |
| 7 | +ENV NPM_CONFIG_PROGRESS=true |
| 8 | +ENV NPM_CONFIG_FETCH_TIMEOUT=600000 |
| 9 | +ENV NPM_CONFIG_FETCH_RETRY_MINTIMEOUT=20000 |
| 10 | +ENV NPM_CONFIG_FETCH_RETRY_MAXTIMEOUT=120000 |
3 | 11 |
|
4 | 12 | # Install Python2, symlink, and C++ build tools for node-gyp/node-sass |
5 | 13 | RUN apt-get update && \ |
6 | 14 | apt-get install -y --no-install-recommends \ |
7 | 15 | python2 \ |
8 | 16 | python-is-python2 \ |
9 | 17 | make \ |
10 | | - g++ && \ |
| 18 | + g++ \ |
| 19 | + curl \ |
| 20 | + wget \ |
| 21 | + gnupg \ |
| 22 | + ca-certificates \ |
| 23 | + xvfb && \ |
11 | 24 | rm -rf /var/lib/apt/lists/* |
12 | 25 |
|
13 | 26 | WORKDIR /code |
14 | 27 |
|
15 | | -# Add dependencies |
16 | | -ADD ./package.json /code |
17 | | -ADD ./bower.json /code |
18 | | -ADD ./gulpfile.js /code |
19 | | -ADD ./.eslintrc /code |
20 | | -ADD ./karma.conf.js /code |
21 | | - |
22 | | -# Install Prerequisites |
23 | | -RUN npm install -g bower gulp gulp-cli |
24 | | -RUN npm link gulp |
25 | | -RUN npm cache clean -f |
26 | | -RUN npm install |
27 | | -RUN npm install -g karma-cli |
28 | | -RUN npm install -g qs |
29 | | -RUN bower install --allow-root |
| 28 | +# Copy package files first for better caching |
| 29 | +COPY package.json bower.json gulpfile.js .eslintrc karma.conf.js .npmrc ./ |
| 30 | + |
| 31 | +# Configure npm with better settings for Docker builds |
| 32 | +RUN npm config set fetch-timeout 600000 && \ |
| 33 | + npm config set fetch-retry-mintimeout 20000 && \ |
| 34 | + npm config set fetch-retry-maxtimeout 120000 && \ |
| 35 | + npm config set progress true && \ |
| 36 | + npm config set loglevel verbose && \ |
| 37 | + npm config set maxsockets 50 |
| 38 | + |
| 39 | +# Install global dependencies first with optimizations and progress |
| 40 | +RUN npm install -g bower gulp gulp-cli karma-cli qs --no-audit --no-fund --progress --verbose && \ |
| 41 | + npm link gulp && \ |
| 42 | + npm cache clean -f |
| 43 | + |
| 44 | +# Install project dependencies with optimizations and progress |
| 45 | +RUN npm install --only=production --no-audit --no-fund --prefer-offline --progress --verbose |
30 | 46 |
|
31 | 47 | # AMD64-specific stage |
32 | 48 | FROM base AS amd64 |
33 | | -RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - |
34 | | -RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' |
35 | | -RUN apt-get update && apt-get install -yq google-chrome-stable libxss1 |
| 49 | +RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \ |
| 50 | + sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && \ |
| 51 | + apt-get update && apt-get install -yq google-chrome-stable libxss1 && \ |
| 52 | + rm -rf /var/lib/apt/lists/* |
36 | 53 |
|
37 | 54 | # ARM64-specific stage |
38 | 55 | FROM base AS arm64 |
39 | | -RUN apt-get update && apt-get install -yq chromium libxss1 |
40 | | -RUN ln -sf /usr/bin/chromium /usr/bin/google-chrome |
| 56 | +RUN apt-get update && apt-get install -yq chromium libxss1 && \ |
| 57 | + ln -sf /usr/bin/chromium /usr/bin/google-chrome && \ |
| 58 | + rm -rf /var/lib/apt/lists/* |
41 | 59 |
|
42 | 60 | # Final stage - automatically selects the right architecture |
43 | 61 | FROM ${TARGETARCH:-amd64} |
44 | 62 |
|
| 63 | +# Set Chrome environment variables for Travis CI |
| 64 | +ENV CHROME_BIN=/usr/bin/google-chrome |
| 65 | +ENV CHROME_PATH=/usr/bin/google-chrome |
| 66 | +ENV DISPLAY=:99.0 |
| 67 | + |
| 68 | +# Copy source code |
| 69 | +COPY . /code/ |
| 70 | + |
| 71 | +# Install bower components after source code is copied |
| 72 | +RUN bower install --allow-root |
| 73 | + |
45 | 74 | # Set common command and expose port |
46 | 75 | CMD ["gulp", "dev:runserver"] |
47 | 76 | EXPOSE 8888 |
0 commit comments