mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Merge pull request #72 from Human-Connection/multistage-build
Reduce image size with multistage builds
This commit is contained in:
commit
aed2a73d13
@ -18,8 +18,8 @@ before_install:
|
||||
- sudo mv docker-compose /usr/local/bin
|
||||
|
||||
install:
|
||||
- docker build --build-arg BUILD_COMMIT=$TRAVIS_COMMIT -t humanconnection/nitro-backend:latest .
|
||||
- docker-compose -f docker-compose.yml up -d
|
||||
- docker build --build-arg BUILD_COMMIT=$TRAVIS_COMMIT --target production -t humanconnection/nitro-backend:latest .
|
||||
- docker-compose -f docker-compose.yml -f docker-compose.travis.yml up -d
|
||||
|
||||
script:
|
||||
- docker-compose exec backend yarn run lint
|
||||
|
||||
27
Dockerfile
27
Dockerfile
@ -1,20 +1,23 @@
|
||||
FROM node:10-alpine
|
||||
FROM node:10-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 the app port
|
||||
EXPOSE 4000
|
||||
|
||||
ARG BUILD_COMMIT
|
||||
ENV BUILD_COMMIT=$BUILD_COMMIT
|
||||
ARG WORKDIR=/nitro-backend
|
||||
RUN mkdir -p $WORKDIR
|
||||
WORKDIR $WORKDIR
|
||||
|
||||
# Install the Application Dependencies
|
||||
COPY package.json .
|
||||
COPY yarn.lock .
|
||||
RUN yarn install --production=false --frozen-lockfile --non-interactive
|
||||
|
||||
COPY . .
|
||||
COPY package.json yarn.lock ./
|
||||
COPY .env.template .env
|
||||
|
||||
RUN yarn run build
|
||||
CMD ["yarn", "run", "start"]
|
||||
|
||||
FROM base as builder
|
||||
RUN yarn install --frozen-lockfile --non-interactive
|
||||
COPY . .
|
||||
RUN yarn run build
|
||||
|
||||
# reduce image size with a multistage build
|
||||
FROM base as production
|
||||
ENV NODE_ENV=production
|
||||
COPY --from=builder /nitro-backend/dist ./dist
|
||||
RUN yarn install --frozen-lockfile --non-interactive
|
||||
|
||||
@ -2,9 +2,14 @@ version: "3.7"
|
||||
|
||||
services:
|
||||
backend:
|
||||
image: humanconnection/nitro-backend:builder
|
||||
build:
|
||||
context: .
|
||||
target: builder
|
||||
volumes:
|
||||
- .:/nitro-backend
|
||||
- /nitro-backend/node_modules
|
||||
command: yarn run dev
|
||||
neo4j:
|
||||
ports:
|
||||
- 7687:7687
|
||||
|
||||
8
docker-compose.travis.yml
Normal file
8
docker-compose.travis.yml
Normal file
@ -0,0 +1,8 @@
|
||||
version: "3.7"
|
||||
|
||||
services:
|
||||
backend:
|
||||
image: humanconnection/nitro-backend:builder
|
||||
build:
|
||||
context: .
|
||||
target: builder
|
||||
@ -3,7 +3,9 @@ version: "3.7"
|
||||
services:
|
||||
backend:
|
||||
image: humanconnection/nitro-backend:latest
|
||||
build: .
|
||||
build:
|
||||
context: .
|
||||
target: production
|
||||
networks:
|
||||
- hc-network
|
||||
depends_on:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user