mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-12 23:35:58 +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
|
||||
|
||||
install:
|
||||
- docker-compose -f docker-compose.yml -f docker-compose.travis.yml up --build -d
|
||||
# avoid "Database constraints have changed after this transaction started"
|
||||
- docker-compose -f docker-compose.yml build --parallel
|
||||
- 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
|
||||
- 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 -d backend yarn run test:before:seeder
|
||||
# Fullstack
|
||||
- docker-compose down
|
||||
- docker-compose -f docker-compose.yml up -d
|
||||
- wait-on http://localhost:7474
|
||||
- yarn run cypress:run
|
||||
# Coverage
|
||||
- yarn run codecov
|
||||
|
||||
@ -14,7 +14,7 @@ COPY package.json yarn.lock ./
|
||||
COPY .env.template .env
|
||||
CMD ["yarn", "run", "start"]
|
||||
|
||||
FROM base as builder
|
||||
FROM base as build-and-test
|
||||
RUN yarn install --production=false --frozen-lockfile --non-interactive
|
||||
COPY . .
|
||||
RUN cp .env.template .env
|
||||
@ -23,6 +23,6 @@ RUN NODE_ENV=production 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
|
||||
COPY --from=build-and-test /nitro-backend/dist ./dist
|
||||
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
|
||||
volumes:
|
||||
- ./webapp:/nitro-web
|
||||
- webapp_node_modules:/nitro-web/node_modules
|
||||
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:
|
||||
image: humanconnection/nitro-backend:builder
|
||||
build:
|
||||
context: backend
|
||||
target: builder
|
||||
target: build-and-test
|
||||
volumes:
|
||||
- ./backend:/nitro-backend
|
||||
- backend_node_modules:/nitro-backend/node_modules
|
||||
- uploads:/nitro-backend/public/uploads
|
||||
command: yarn run dev
|
||||
environment:
|
||||
- SMTP_HOST=mailserver
|
||||
- SMTP_PORT=25
|
||||
- SMTP_IGNORE_TLS=true
|
||||
- "DEBUG=${DEBUG}"
|
||||
neo4j:
|
||||
environment:
|
||||
- NEO4J_AUTH=none
|
||||
ports:
|
||||
- 7687:7687
|
||||
- 7474:7474
|
||||
volumes:
|
||||
- neo4j-data:/data
|
||||
maintenance:
|
||||
image: humanconnection/maintenance:latest
|
||||
build:
|
||||
@ -74,9 +36,5 @@ services:
|
||||
ports:
|
||||
- 3503:80
|
||||
|
||||
volumes:
|
||||
webapp_node_modules:
|
||||
backend_node_modules:
|
||||
factories_node_modules:
|
||||
neo4j-data:
|
||||
uploads:
|
||||
networks:
|
||||
hc-network:
|
||||
|
||||
@ -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
|
||||
networks:
|
||||
- hc-network
|
||||
volumes:
|
||||
- webapp_node_modules:/nitro-web/node_modules
|
||||
- webapp_nuxt_folder:/nitro-web/.nuxt
|
||||
environment:
|
||||
- HOST=0.0.0.0
|
||||
- GRAPHQL_URI=http://backend:4000
|
||||
@ -25,6 +28,9 @@ services:
|
||||
- neo4j
|
||||
ports:
|
||||
- 4000:4000
|
||||
volumes:
|
||||
- backend_node_modules:/nitro-backend/node_modules
|
||||
- uploads:/nitro-backend/public/uploads
|
||||
environment:
|
||||
- NEO4J_URI=bolt://neo4j:7687
|
||||
- GRAPHQL_PORT=4000
|
||||
@ -39,6 +45,19 @@ services:
|
||||
context: neo4j
|
||||
networks:
|
||||
- hc-network
|
||||
environment:
|
||||
- NEO4J_AUTH=none
|
||||
ports:
|
||||
- 7687:7687
|
||||
- 7474:7474
|
||||
volumes:
|
||||
- neo4j_data:/data
|
||||
|
||||
networks:
|
||||
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
|
||||
RUN apk --no-cache add git
|
||||
|
||||
COPY . .
|
||||
|
||||
FROM base as build-and-test
|
||||
COPY . .
|
||||
RUN cp .env.template .env
|
||||
RUN yarn install --production=false --frozen-lockfile --non-interactive
|
||||
RUN NODE_ENV=production yarn run build
|
||||
|
||||
FROM base as production
|
||||
ENV NODE_ENV=production
|
||||
COPY --from=build-and-test ./nitro-web/node_modules ./node_modules
|
||||
COPY package.json yarn.lock ./
|
||||
RUN yarn install --production=true --frozen-lockfile --non-interactive
|
||||
COPY --from=build-and-test ./nitro-web/.nuxt ./.nuxt
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user