diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index de956e17b..1c7927665 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -4,6 +4,7 @@ on: push: branches: - master + # - 4451-new-deployment-with-base-and-code # for testing while developing jobs: ############################################################################## @@ -92,7 +93,10 @@ jobs: # BUILD BACKEND DOCKER IMAGE (production) ################################ ########################################################################## - name: Backend | Build `production` image - run: docker build --target production -t "ocelotsocialnetwork/backend:latest" -t "ocelotsocialnetwork/backend:${VERSION}" -t "ocelotsocialnetwork/backend:${BUILD_VERSION}" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT backend/ + run: | + docker build --target base -t "ocelotsocialnetwork/backend:latest-base" -t "ocelotsocialnetwork/backend:${VERSION}-base" -t "ocelotsocialnetwork/backend:${BUILD_VERSION}-base" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT backend/ + docker build --target code -t "ocelotsocialnetwork/backend:latest-code" -t "ocelotsocialnetwork/backend:${VERSION}-code" -t "ocelotsocialnetwork/backend:${BUILD_VERSION}-code" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT backend/ + docker build --target production -t "ocelotsocialnetwork/backend:latest" -t "ocelotsocialnetwork/backend:${VERSION}" -t "ocelotsocialnetwork/backend:${BUILD_VERSION}" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT backend/ - name: Backend | Save docker image run: docker save "ocelotsocialnetwork/backend" > /tmp/backend.tar - name: Upload Artifact @@ -129,7 +133,10 @@ jobs: # BUILD WEBAPP DOCKER IMAGE (build) ###################################### ########################################################################## - name: Webapp | Build `production` image - run: docker build --target production -t "ocelotsocialnetwork/webapp:latest" -t "ocelotsocialnetwork/webapp:${VERSION}" -t "ocelotsocialnetwork/webapp:${BUILD_VERSION}" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT webapp/ + run: | + docker build --target base -t "ocelotsocialnetwork/webapp:latest-base" -t "ocelotsocialnetwork/webapp:${VERSION}-base" -t "ocelotsocialnetwork/webapp:${BUILD_VERSION}-base" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT webapp/ + docker build --target code -t "ocelotsocialnetwork/webapp:latest-code" -t "ocelotsocialnetwork/webapp:${VERSION}-code" -t "ocelotsocialnetwork/webapp:${BUILD_VERSION}-code" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT webapp/ + docker build --target production -t "ocelotsocialnetwork/webapp:latest" -t "ocelotsocialnetwork/webapp:${VERSION}" -t "ocelotsocialnetwork/webapp:${BUILD_VERSION}" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT webapp/ - name: Webapp | Save docker image run: docker save "ocelotsocialnetwork/webapp" > /tmp/webapp.tar - name: Upload Artifact @@ -166,7 +173,10 @@ jobs: # BUILD MAINTENANCE DOCKER IMAGE (build) ################################# ########################################################################## - name: Maintenance | Build `production` image - run: docker build --target production -t "ocelotsocialnetwork/maintenance:latest" -t "ocelotsocialnetwork/maintenance:${VERSION}" -t "ocelotsocialnetwork/maintenance:${BUILD_VERSION}" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT webapp/ -f webapp/Dockerfile.maintenance + run: | + docker build --target base -t "ocelotsocialnetwork/maintenance:latest-base" -t "ocelotsocialnetwork/maintenance:${VERSION}-base" -t "ocelotsocialnetwork/maintenance:${BUILD_VERSION}-base" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT webapp/ -f webapp/Dockerfile.maintenance + docker build --target code -t "ocelotsocialnetwork/maintenance:latest-code" -t "ocelotsocialnetwork/maintenance:${VERSION}-code" -t "ocelotsocialnetwork/maintenance:${BUILD_VERSION}-code" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT webapp/ -f webapp/Dockerfile.maintenance + docker build --target production -t "ocelotsocialnetwork/maintenance:latest" -t "ocelotsocialnetwork/maintenance:${VERSION}" -t "ocelotsocialnetwork/maintenance:${BUILD_VERSION}" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT webapp/ -f webapp/Dockerfile.maintenance - name: Maintenance | Save docker image run: docker save "ocelotsocialnetwork/maintenance" > /tmp/maintenance.tar - name: Upload Artifact diff --git a/backend/Dockerfile b/backend/Dockerfile index c632f8803..0ebdfb1eb 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,5 +1,5 @@ ################################################################################## -# BASE ########################################################################### +# BASE (Is pushed to DockerHub for rebranding) ################################### ################################################################################## FROM node:12.19.0-alpine3.10 as base @@ -59,12 +59,18 @@ FROM base as development CMD /bin/sh -c "yarn install && yarn run dev" ################################################################################## -# BUILD (Does contain all files and is therefore bloated) ######################## +# CODE (Does contain all code files and is pushed to DockerHub for rebranding) ### ################################################################################## -FROM base as build +FROM base as code -# Copy everything +# copy everything, but do not build. COPY . . + +################################################################################## +# BUILD (Does contain all files and the compilate and is therefore bloated) ###### +################################################################################## +FROM code as build + # yarn install RUN yarn install --production=false --frozen-lockfile --non-interactive # yarn build @@ -85,7 +91,6 @@ FROM base as production # Copy "binary"-files from build image COPY --from=build ${DOCKER_WORKDIR}/dist ./dist -COPY --from=build ${DOCKER_WORKDIR}/node_modules ./node_modules # Copy static files # TODO - externalize the uploads so we can copy the whole folder COPY --from=build ${DOCKER_WORKDIR}/public/img/ ./public/img/ @@ -94,4 +99,4 @@ COPY --from=build ${DOCKER_WORKDIR}/public/providers.json ./public/providers.jso COPY --from=build ${DOCKER_WORKDIR}/package.json ./package.json # Run command -CMD /bin/sh -c "yarn run start" \ No newline at end of file +CMD /bin/sh -c "yarn run start" diff --git a/backend/package.json b/backend/package.json index 9787253a1..8b10f632d 100644 --- a/backend/package.json +++ b/backend/package.json @@ -39,6 +39,12 @@ ] }, "dependencies": { + "@babel/cli": "~7.8.4", + "@babel/core": "~7.9.0", + "@babel/node": "~7.8.7", + "@babel/plugin-proposal-throw-expressions": "^7.8.3", + "@babel/preset-env": "~7.9.5", + "@babel/register": "^7.9.0", "@hapi/joi": "^17.1.1", "@sentry/node": "^5.15.4", "apollo-cache-inmemory": "~1.6.5", @@ -48,6 +54,9 @@ "apollo-server": "~2.14.2", "apollo-server-express": "^2.14.2", "aws-sdk": "^2.652.0", + "babel-core": "~7.0.0-0", + "babel-eslint": "~10.1.0", + "babel-jest": "~25.2.6", "babel-plugin-transform-runtime": "^6.23.0", "bcryptjs": "~2.4.3", "cheerio": "~1.0.0-rc.3", @@ -111,16 +120,7 @@ "xregexp": "^4.3.0" }, "devDependencies": { - "@babel/cli": "~7.8.4", - "@babel/core": "~7.9.0", - "@babel/node": "~7.8.7", - "@babel/plugin-proposal-throw-expressions": "^7.8.3", - "@babel/preset-env": "~7.9.5", - "@babel/register": "^7.9.0", "apollo-server-testing": "~2.11.0", - "babel-core": "~7.0.0-0", - "babel-eslint": "~10.1.0", - "babel-jest": "~25.2.6", "chai": "~4.2.0", "cucumber": "~6.0.5", "eslint": "~6.8.0", diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 8d1bb96f2..5fceb2776 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -18,7 +18,6 @@ services: - webapp_node_modules:/app/node_modules # bind the local folder to the docker to allow live reload - ./webapp:/app - ######################################################## # BACKEND ############################################## ######################################################## @@ -35,7 +34,6 @@ services: - backend_node_modules:/app/node_modules # bind the local folder to the docker to allow live reload - ./backend:/app - ######################################################## # NEO4J ################################################ ######################################################## @@ -47,13 +45,11 @@ services: networks: # So we can access the neo4j query browser from our host machine - external-net - ######################################################## # MAINTENANCE ########################################## ######################################################## maintenance: image: ocelotsocialnetwork/maintenance:development - ######################################################## # MAILSERVER TO FAKE SMTP ############################## ######################################################## @@ -63,6 +59,7 @@ services: - 1080:80 networks: - external-net + volumes: webapp_node_modules: backend_node_modules: diff --git a/docker-compose.test.yml b/docker-compose.test.yml index eef71e67b..973cf87cf 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -12,7 +12,6 @@ services: - NODE_ENV="test" volumes: - ./coverage:/app/coverage - ######################################################## # BACKEND ############################################## ######################################################## @@ -24,7 +23,6 @@ services: - NODE_ENV="test" volumes: - ./coverage:/app/coverage - ######################################################## # NEO4J ################################################ ######################################################## @@ -41,13 +39,11 @@ services: networks: # So we can access the neo4j query browser from our host machine - external-net - ######################################################## # MAINTENANCE ########################################## ######################################################## maintenance: image: ocelotsocialnetwork/maintenance:test - ######################################################## # MAILSERVER TO FAKE SMTP ############################## ######################################################## @@ -57,6 +53,7 @@ services: - 1080:80 networks: - external-net + volumes: webapp_node_modules: backend_node_modules: diff --git a/docker-compose.yml b/docker-compose.yml index 392447f61..d20bb6aec 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -35,7 +35,6 @@ services: - GRAPHQL_URI=http://backend:4000 env_file: - ./webapp/.env - ######################################################## # BACKEND ############################################## ######################################################## @@ -68,7 +67,6 @@ services: - CLIENT_URI=http://webapp:3000 env_file: - ./backend/.env - ######################################################## # NEO4J ################################################ ######################################################## @@ -92,7 +90,6 @@ services: # TODO: clarify if that is the only thing needed to unlock the Enterprise version # - NEO4J_ACCEPT_LICENSE_AGREEMENT=yes # TODO: Remove the playground from production - ######################################################## # MAINTENANCE ########################################## ######################################################## diff --git a/webapp/Dockerfile b/webapp/Dockerfile index 75d43bf59..8d830a9d5 100644 --- a/webapp/Dockerfile +++ b/webapp/Dockerfile @@ -1,5 +1,5 @@ ################################################################################## -# BASE ########################################################################### +# BASE (Is pushed to DockerHub for rebranding) ################################### ################################################################################## FROM node:12.19.0-alpine3.10 as base @@ -59,12 +59,18 @@ FROM base as development CMD /bin/sh -c "yarn install && yarn run dev" ################################################################################## -# BUILD (Does contain all files and is therefore bloated) ######################## +# CODE (Does contain all code files and is pushed to DockerHub for rebranding) ### ################################################################################## -FROM base as build +FROM base as code -# Copy everything +# copy everything, but do not build. COPY . . + +################################################################################## +# BUILD (Does contain all files and the compilate and is therefore bloated) ###### +################################################################################## +FROM code as build + # yarn install RUN yarn install --production=false --frozen-lockfile --non-interactive # yarn build @@ -83,18 +89,13 @@ CMD /bin/sh -c "yarn run dev" ################################################################################## FROM base as production +# TODO - do all copying with one COPY command to have one layer # Copy "binary"-files from build image COPY --from=build ${DOCKER_WORKDIR}/.nuxt ./.nuxt COPY --from=build ${DOCKER_WORKDIR}/node_modules ./node_modules COPY --from=build ${DOCKER_WORKDIR}/nuxt.config.js ./nuxt.config.js -# Copy static files -# TODO - this should be one Folder containign all stuff needed to be copied -COPY --from=build ${DOCKER_WORKDIR}/config/ ./config/ -COPY --from=build ${DOCKER_WORKDIR}/constants ./constants -COPY --from=build ${DOCKER_WORKDIR}/static ./static -COPY --from=build ${DOCKER_WORKDIR}/locales ./locales # Copy package.json for script definitions (lock file should not be needed) COPY --from=build ${DOCKER_WORKDIR}/package.json ./package.json # Run command -CMD /bin/sh -c "yarn run start" \ No newline at end of file +CMD /bin/sh -c "yarn run start" diff --git a/webapp/Dockerfile.maintenance b/webapp/Dockerfile.maintenance index 0a7616240..dcc06ad61 100644 --- a/webapp/Dockerfile.maintenance +++ b/webapp/Dockerfile.maintenance @@ -48,11 +48,12 @@ WORKDIR ${DOCKER_WORKDIR} CMD ["yarn", "run", "start"] ################################################################################## -# BUILD ### TODO # TODO # TODO # TODO # TODO # TODO # TODO # TODO # TODO # TODO ## +# CODE (Does contain all code files and is pushed to DockerHub for rebranding) ### ################################################################################## -FROM base as build +FROM base as code COPY package.json yarn.lock ./ +# yarn install RUN yarn install --production=false --frozen-lockfile --non-interactive COPY assets assets @@ -67,10 +68,17 @@ COPY constants constants COPY nuxt.config.js nuxt.config.js COPY config/ config/ +# this is needed in rebranding +COPY maintenance/nginx maintenance/nginx # this will also ovewrite the existing package.json COPY maintenance/source ./ +################################################################################## +# BUILD ### TODO # TODO # TODO # TODO # TODO # TODO # TODO # TODO # TODO # TODO ## +################################################################################## +FROM code as build +# yarn generate RUN yarn run generate ################################################################################## diff --git a/webapp/constants/metadata.js b/webapp/constants/metadata.js index d40308e80..da313c7fb 100644 --- a/webapp/constants/metadata.js +++ b/webapp/constants/metadata.js @@ -1,7 +1,7 @@ // this file is duplicated in `backend/src/config/metadata.js` and `webapp/constants/metadata.js` and replaced on rebranding export default { APPLICATION_NAME: 'ocelot.social', - APPLICATION_SHORT_NAME: 'ocelot', + APPLICATION_SHORT_NAME: 'ocelot.social', APPLICATION_DESCRIPTION: 'ocelot.social Community Network', COOKIE_NAME: 'ocelot-social-token', ORGANIZATION_NAME: 'ocelot.social Community',