2019-04-06 00:45:34 +03:00
|
|
|
FROM node:10-alpine AS build
|
2017-09-13 23:21:00 +03:00
|
|
|
|
2019-04-06 00:45:34 +03:00
|
|
|
ARG NPM_TOKEN
|
|
|
|
|
|
|
|
# Make Git available for NPM and rsync in the build image
|
|
|
|
RUN apk add --update git rsync && \
|
|
|
|
rm -rf /tmp/* /var/cache/apk/*
|
|
|
|
|
|
|
|
COPY . /tmp/
|
2019-08-07 02:53:50 +03:00
|
|
|
|
|
|
|
# Only if needed, copy .npmrc files into the container
|
|
|
|
# COPY Dockerfile.npmrc /tmp/.npmrc
|
|
|
|
# COPY .npmrc /tmp/.npmrc
|
2019-04-06 00:45:34 +03:00
|
|
|
|
|
|
|
RUN cd /tmp && npm install --production --verbose
|
|
|
|
RUN rsync -azhqi /tmp/node_modules/ /tmp/production_node_modules
|
|
|
|
|
|
|
|
# Dev dependencies
|
|
|
|
RUN cd /tmp && npm install --verbose
|
|
|
|
RUN rm -rf /tmp/.npmrc
|
|
|
|
|
|
|
|
# TypeScript build
|
2020-04-15 01:57:21 +03:00
|
|
|
RUN cd /tmp && node ./node_modules/typescript/bin/tsc
|
2019-04-06 00:45:34 +03:00
|
|
|
|
|
|
|
FROM node:10-alpine AS run
|
2017-09-13 23:21:00 +03:00
|
|
|
ENV APPDIR=/usr/src/repos
|
|
|
|
|
2019-04-06 00:45:34 +03:00
|
|
|
RUN mkdir -p "${APPDIR}"
|
|
|
|
|
|
|
|
# Production Node.js modules
|
|
|
|
COPY --from=build /tmp/production_node_modules "${APPDIR}/node_modules"
|
|
|
|
|
|
|
|
# Assets that people not using painless config may need
|
2019-08-07 02:53:50 +03:00
|
|
|
COPY --from=build /tmp/data "${APPDIR}/data"
|
2019-04-06 00:45:34 +03:00
|
|
|
|
|
|
|
# Copy built assets, app, config map
|
|
|
|
COPY --from=build /tmp/dist "${APPDIR}"
|
|
|
|
COPY --from=build /tmp/config "${APPDIR}/config"
|
|
|
|
COPY --from=build /tmp/views "${APPDIR}/views"
|
|
|
|
COPY --from=build /tmp/package.json "${APPDIR}/package.json"
|
|
|
|
COPY --from=build /tmp/jobs/reports/exemptRepositories.json "${APPDIR}/jobs/reports/"
|
|
|
|
COPY --from=build /tmp/jobs/reports/organizationDefinitions.json "${APPDIR}/jobs/reports/"
|
|
|
|
COPY --from=build /tmp/jobs/reports/repositoryDefinitions.json "${APPDIR}/jobs/reports/"
|
|
|
|
COPY --from=build /tmp/jobs/reports/teamDefinitions.json "${APPDIR}/jobs/reports/"
|
|
|
|
COPY --from=build /tmp/jobs/reports/views "${APPDIR}/jobs/reports/views"
|
|
|
|
|
|
|
|
WORKDIR /usr/src/repos
|
|
|
|
|
|
|
|
# COPY package.json "${APPDIR}"
|
|
|
|
# COPY views "${APPDIR}/views"
|
|
|
|
# COPY dist "${APPDIR}"
|
|
|
|
# COPY public "${APPDIR}/public"
|
2017-09-13 23:21:00 +03:00
|
|
|
|
|
|
|
ENV IS_DOCKER=1
|
2020-04-15 01:57:21 +03:00
|
|
|
ENV DEBUG=startup
|
2017-09-13 23:21:00 +03:00
|
|
|
|
|
|
|
ENV NPM_CONFIG_LOGLEVEL=warn
|
|
|
|
|
2019-04-06 00:45:34 +03:00
|
|
|
ENV PORT 3000
|
|
|
|
EXPOSE 3000
|
2017-09-13 23:21:00 +03:00
|
|
|
|
2019-04-06 00:45:34 +03:00
|
|
|
RUN addgroup oss && adduser -D -G oss oss \
|
|
|
|
&& chown -R oss:oss "${APPDIR}"
|
|
|
|
USER oss
|
2017-09-13 23:21:00 +03:00
|
|
|
|
2019-04-06 00:45:34 +03:00
|
|
|
ENTRYPOINT ["npm", "run-script", "start-in-container"]
|