mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
* Use `production` docker images for cypress tests. As one of our contributors pointed out: It is bad practice to end-to-end test sth. else than the actual production images. * Have a dedicated `docker-compose.travis-integration.yml` to test backend integration tests. The backend *needs* a database when doing integration tests. So there is no way around using docker-compose. But we could stop using the `build-and-test` stage when we do cypress tests. * Remove a couple of unused ports and DRY `docker-compose.override.yml` * Build and tag all images first and then run `docker-compose .. up` - I hope this will not rebuild the image. * Reduce docker image size
29 lines
887 B
Docker
29 lines
887 B
Docker
FROM node:12.10.0-alpine as base
|
|
LABEL Description="Backend of the Social Network Human-Connection.org" Vendor="Human Connection gGmbH" Version="0.0.1" Maintainer="Human Connection gGmbH (developer@human-connection.org)"
|
|
|
|
EXPOSE 4000
|
|
ARG BUILD_COMMIT
|
|
ENV BUILD_COMMIT=$BUILD_COMMIT
|
|
ARG WORKDIR=/nitro-backend
|
|
RUN mkdir -p $WORKDIR
|
|
WORKDIR $WORKDIR
|
|
|
|
RUN apk --no-cache add git
|
|
|
|
COPY package.json yarn.lock ./
|
|
COPY .env.template .env
|
|
CMD ["yarn", "run", "start"]
|
|
|
|
FROM base as build-and-test
|
|
RUN yarn install --production=false --frozen-lockfile --non-interactive
|
|
COPY . .
|
|
RUN cp .env.template .env
|
|
RUN NODE_ENV=production yarn run build
|
|
|
|
# reduce image size with a multistage build
|
|
FROM base as production
|
|
ENV NODE_ENV=production
|
|
COPY --from=build-and-test /nitro-backend/dist ./dist
|
|
COPY ./public/img/ ./public/img/
|
|
RUN yarn install --production=true --frozen-lockfile --non-interactive
|