mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Various changes to build pipeline
* 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
This commit is contained in:
parent
6ff532ab4a
commit
10418f061b
@ -15,8 +15,9 @@ before_install:
|
|||||||
- cp cypress.env.template.json cypress.env.json
|
- cp cypress.env.template.json cypress.env.json
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- docker-compose -f docker-compose.yml -f docker-compose.travis.yml up --build -d
|
- docker-compose -f docker-compose.yml build --parallel
|
||||||
# avoid "Database constraints have changed after this transaction started"
|
- docker-compose -f docker-compose.yml -f docker-compose.build-and-test.yml build # just tagging, just be quite fast
|
||||||
|
- docker-compose -f docker-compose.yml -f docker-compose.build-and-test.yml up -d
|
||||||
- wait-on http://localhost:7474
|
- wait-on http://localhost:7474
|
||||||
- docker-compose exec neo4j db_setup
|
- docker-compose exec neo4j db_setup
|
||||||
|
|
||||||
@ -38,6 +39,9 @@ script:
|
|||||||
- docker-compose exec webapp yarn run test --ci --verbose=false --coverage
|
- docker-compose exec webapp yarn run test --ci --verbose=false --coverage
|
||||||
- docker-compose exec -d backend yarn run test:before:seeder
|
- docker-compose exec -d backend yarn run test:before:seeder
|
||||||
# Fullstack
|
# Fullstack
|
||||||
|
- docker-compose down
|
||||||
|
- docker-compose -f docker-compose.yml up -d
|
||||||
|
- wait-on http://localhost:7474
|
||||||
- yarn run cypress:run
|
- yarn run cypress:run
|
||||||
# Coverage
|
# Coverage
|
||||||
- yarn run codecov
|
- yarn run codecov
|
||||||
|
|||||||
@ -14,7 +14,7 @@ COPY package.json yarn.lock ./
|
|||||||
COPY .env.template .env
|
COPY .env.template .env
|
||||||
CMD ["yarn", "run", "start"]
|
CMD ["yarn", "run", "start"]
|
||||||
|
|
||||||
FROM base as builder
|
FROM base as build-and-test
|
||||||
RUN yarn install --production=false --frozen-lockfile --non-interactive
|
RUN yarn install --production=false --frozen-lockfile --non-interactive
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN cp .env.template .env
|
RUN cp .env.template .env
|
||||||
@ -23,6 +23,6 @@ RUN NODE_ENV=production yarn run build
|
|||||||
# reduce image size with a multistage build
|
# reduce image size with a multistage build
|
||||||
FROM base as production
|
FROM base as production
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
COPY --from=builder /nitro-backend/dist ./dist
|
COPY --from=build-and-test /nitro-backend/dist ./dist
|
||||||
COPY ./public/img/ ./public/img/
|
COPY ./public/img/ ./public/img/
|
||||||
RUN yarn install --frozen-lockfile --non-interactive
|
RUN yarn install --production=true --frozen-lockfile --non-interactive
|
||||||
|
|||||||
13
docker-compose.build-and-test.yml
Normal file
13
docker-compose.build-and-test.yml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
version: "3.4"
|
||||||
|
|
||||||
|
services:
|
||||||
|
webapp:
|
||||||
|
image: humanconnection/nitro-web:build-and-test
|
||||||
|
build:
|
||||||
|
context: webapp
|
||||||
|
target: build-and-test
|
||||||
|
backend:
|
||||||
|
image: humanconnection/nitro-backend:build-and-test
|
||||||
|
build:
|
||||||
|
context: backend
|
||||||
|
target: build-and-test
|
||||||
@ -13,57 +13,19 @@ services:
|
|||||||
target: build-and-test
|
target: build-and-test
|
||||||
volumes:
|
volumes:
|
||||||
- ./webapp:/nitro-web
|
- ./webapp:/nitro-web
|
||||||
- webapp_node_modules:/nitro-web/node_modules
|
|
||||||
command: yarn run dev
|
command: yarn run dev
|
||||||
environment:
|
|
||||||
- NUXT_BUILD=.nuxt-dist # avoid file ownership issues with shared folders
|
|
||||||
factories:
|
|
||||||
image: humanconnection/nitro-backend:builder
|
|
||||||
build:
|
|
||||||
context: backend
|
|
||||||
target: builder
|
|
||||||
ports:
|
|
||||||
- 4001:4001
|
|
||||||
networks:
|
|
||||||
- hc-network
|
|
||||||
volumes:
|
|
||||||
- ./backend:/nitro-backend
|
|
||||||
- factories_node_modules:/nitro-backend/node_modules
|
|
||||||
- uploads:/nitro-backend/public/uploads
|
|
||||||
depends_on:
|
|
||||||
- neo4j
|
|
||||||
environment:
|
|
||||||
- NEO4J_URI=bolt://neo4j:7687
|
|
||||||
- GRAPHQL_PORT=4000
|
|
||||||
- GRAPHQL_URI=http://localhost:4000
|
|
||||||
- CLIENT_URI=http://localhost:3000
|
|
||||||
- JWT_SECRET=b/&&7b78BF&fv/Vd
|
|
||||||
- MAPBOX_TOKEN=pk.eyJ1IjoiaHVtYW4tY29ubmVjdGlvbiIsImEiOiJjajl0cnBubGoweTVlM3VwZ2lzNTNud3ZtIn0.KZ8KK9l70omjXbEkkbHGsQ
|
|
||||||
- PRIVATE_KEY_PASSPHRASE=a7dsf78sadg87ad87sfagsadg78
|
|
||||||
command: yarn run test:before:seeder
|
|
||||||
backend:
|
backend:
|
||||||
image: humanconnection/nitro-backend:builder
|
|
||||||
build:
|
build:
|
||||||
context: backend
|
context: backend
|
||||||
target: builder
|
target: build-and-test
|
||||||
volumes:
|
volumes:
|
||||||
- ./backend:/nitro-backend
|
- ./backend:/nitro-backend
|
||||||
- backend_node_modules:/nitro-backend/node_modules
|
|
||||||
- uploads:/nitro-backend/public/uploads
|
|
||||||
command: yarn run dev
|
command: yarn run dev
|
||||||
environment:
|
environment:
|
||||||
- SMTP_HOST=mailserver
|
- SMTP_HOST=mailserver
|
||||||
- SMTP_PORT=25
|
- SMTP_PORT=25
|
||||||
- SMTP_IGNORE_TLS=true
|
- SMTP_IGNORE_TLS=true
|
||||||
- "DEBUG=${DEBUG}"
|
- "DEBUG=${DEBUG}"
|
||||||
neo4j:
|
|
||||||
environment:
|
|
||||||
- NEO4J_AUTH=none
|
|
||||||
ports:
|
|
||||||
- 7687:7687
|
|
||||||
- 7474:7474
|
|
||||||
volumes:
|
|
||||||
- neo4j-data:/data
|
|
||||||
maintenance:
|
maintenance:
|
||||||
image: humanconnection/maintenance:latest
|
image: humanconnection/maintenance:latest
|
||||||
build:
|
build:
|
||||||
@ -74,9 +36,5 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- 3503:80
|
- 3503:80
|
||||||
|
|
||||||
volumes:
|
networks:
|
||||||
webapp_node_modules:
|
hc-network:
|
||||||
backend_node_modules:
|
|
||||||
factories_node_modules:
|
|
||||||
neo4j-data:
|
|
||||||
uploads:
|
|
||||||
|
|||||||
@ -1,27 +0,0 @@
|
|||||||
version: "3.4"
|
|
||||||
|
|
||||||
services:
|
|
||||||
neo4j:
|
|
||||||
environment:
|
|
||||||
- NEO4J_AUTH=none
|
|
||||||
ports:
|
|
||||||
- 7687:7687
|
|
||||||
- 7474:7474
|
|
||||||
webapp:
|
|
||||||
build:
|
|
||||||
context: webapp
|
|
||||||
target: build-and-test
|
|
||||||
volumes:
|
|
||||||
#/nitro-web
|
|
||||||
- ./webapp/coverage:/nitro-web/coverage
|
|
||||||
backend:
|
|
||||||
image: humanconnection/nitro-backend:builder
|
|
||||||
build:
|
|
||||||
context: backend
|
|
||||||
target: builder
|
|
||||||
volumes:
|
|
||||||
- ./backend/coverage:/nitro-backend/coverage
|
|
||||||
ports:
|
|
||||||
- 4001:4001
|
|
||||||
- 4123:4123
|
|
||||||
|
|
||||||
@ -10,6 +10,9 @@ services:
|
|||||||
- 3000:3000
|
- 3000:3000
|
||||||
networks:
|
networks:
|
||||||
- hc-network
|
- hc-network
|
||||||
|
volumes:
|
||||||
|
- webapp_node_modules:/nitro-web/node_modules
|
||||||
|
- webapp_nuxt_folder:/nitro-web/.nuxt
|
||||||
environment:
|
environment:
|
||||||
- HOST=0.0.0.0
|
- HOST=0.0.0.0
|
||||||
- GRAPHQL_URI=http://backend:4000
|
- GRAPHQL_URI=http://backend:4000
|
||||||
@ -25,6 +28,9 @@ services:
|
|||||||
- neo4j
|
- neo4j
|
||||||
ports:
|
ports:
|
||||||
- 4000:4000
|
- 4000:4000
|
||||||
|
volumes:
|
||||||
|
- backend_node_modules:/nitro-backend/node_modules
|
||||||
|
- uploads:/nitro-backend/public/uploads
|
||||||
environment:
|
environment:
|
||||||
- NEO4J_URI=bolt://neo4j:7687
|
- NEO4J_URI=bolt://neo4j:7687
|
||||||
- GRAPHQL_PORT=4000
|
- GRAPHQL_PORT=4000
|
||||||
@ -39,6 +45,19 @@ services:
|
|||||||
context: neo4j
|
context: neo4j
|
||||||
networks:
|
networks:
|
||||||
- hc-network
|
- hc-network
|
||||||
|
environment:
|
||||||
|
- NEO4J_AUTH=none
|
||||||
|
ports:
|
||||||
|
- 7687:7687
|
||||||
|
- 7474:7474
|
||||||
|
volumes:
|
||||||
|
- neo4j_data:/data
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
hc-network:
|
hc-network:
|
||||||
|
volumes:
|
||||||
|
webapp_node_modules:
|
||||||
|
webapp_nuxt_folder:
|
||||||
|
backend_node_modules:
|
||||||
|
neo4j_data:
|
||||||
|
uploads:
|
||||||
|
|||||||
@ -14,14 +14,14 @@ WORKDIR $WORKDIR
|
|||||||
# See: https://github.com/nodejs/docker-node/pull/367#issuecomment-430807898
|
# See: https://github.com/nodejs/docker-node/pull/367#issuecomment-430807898
|
||||||
RUN apk --no-cache add git
|
RUN apk --no-cache add git
|
||||||
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
FROM base as build-and-test
|
FROM base as build-and-test
|
||||||
|
COPY . .
|
||||||
RUN cp .env.template .env
|
RUN cp .env.template .env
|
||||||
RUN yarn install --production=false --frozen-lockfile --non-interactive
|
RUN yarn install --production=false --frozen-lockfile --non-interactive
|
||||||
RUN NODE_ENV=production yarn run build
|
RUN NODE_ENV=production yarn run build
|
||||||
|
|
||||||
FROM base as production
|
FROM base as production
|
||||||
ENV NODE_ENV=production
|
COPY package.json yarn.lock ./
|
||||||
COPY --from=build-and-test ./nitro-web/node_modules ./node_modules
|
RUN yarn install --production=true --frozen-lockfile --non-interactive
|
||||||
COPY --from=build-and-test ./nitro-web/.nuxt ./.nuxt
|
COPY --from=build-and-test ./nitro-web/.nuxt ./.nuxt
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user