From 5f9155805d5e6956ce7c0e8522fa92a0463099be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Sun, 17 Jul 2022 20:32:03 +0200 Subject: [PATCH 1/3] Fix 'Dockerfile' for webapp and backend for running locally and in cluster --- backend/Dockerfile | 1 + webapp/Dockerfile | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/backend/Dockerfile b/backend/Dockerfile index 0ebdfb1eb..6c2f72bd3 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -91,6 +91,7 @@ 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/ diff --git a/webapp/Dockerfile b/webapp/Dockerfile index 8d830a9d5..a086a4b2a 100644 --- a/webapp/Dockerfile +++ b/webapp/Dockerfile @@ -94,6 +94,13 @@ FROM base as production 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 seems not be needed anymore for the new rebranding +# 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 From fbbcc5bb854d53b5fa658b83d56d381a3cbc2b1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Sun, 17 Jul 2022 20:35:16 +0200 Subject: [PATCH 2/3] Add documentation for Docker build analyzes --- DOCKER_MORE_CLOSELY.md | 64 ++++++++++++++++++++++++++++++++++++++++++ SUMMARY.md | 1 + 2 files changed, 65 insertions(+) create mode 100644 DOCKER_MORE_CLOSELY.md diff --git a/DOCKER_MORE_CLOSELY.md b/DOCKER_MORE_CLOSELY.md new file mode 100644 index 000000000..e4b40579e --- /dev/null +++ b/DOCKER_MORE_CLOSELY.md @@ -0,0 +1,64 @@ +# Docker More Closely + +## Apple M1 Platform + +***Attention:** For using Docker commands in Apple M1 environments!* + +### Enviroment Variable For Apple M1 Platform + +To set the Docker platform environment variable in your terminal tab, run: + +```bash +# set env variable for your shell +$ export DOCKER_DEFAULT_PLATFORM=linux/amd64 +``` + +## Analysing Docker Builds + +To analyze a Docker build, there is a wonderful tool called [dive](https://github.com/wagoodman/dive). Please sponsor if you're using it! + +The `dive build` command is exactly the right one to fulfill what we are looking for. +We can use it just like the `docker build` command and get an analysis afterwards. + +So, in our main folder, we use it in the following way: + +```bash +# in main folder +$ dive build --target -t "ocelotsocialnetwork/:local-" --build-arg BBUILD_DATE="" --build-arg BBUILD_VERSION="" --build-arg BBUILD_COMMIT="" / +``` + +The build arguments are optional. + +For the specific applications, we use them as follows. + +### Backend + +#### Production For Backend + +```bash +# in main folder +$ dive build --target production -t "ocelotsocialnetwork/backend:local-production" backend/ +``` + +#### Development For Backend + +```bash +# in main folder +$ dive build --target development -t "ocelotsocialnetwork/backend:local-development" backend/ +``` + +### Webapp + +#### Production For Webapp + +```bash +# in main folder +$ dive build --target production -t "ocelotsocialnetwork/webapp:local-production" webapp/ +``` + +#### Development For Webapp + +```bash +# in main folder +$ dive build --target development -t "ocelotsocialnetwork/webapp:local-development" webapp/ +``` diff --git a/SUMMARY.md b/SUMMARY.md index 9c74b1974..f848633d5 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -15,6 +15,7 @@ * [End-to-end tests](cypress/README.md) * [Frontend tests](webapp/testing.md) * [Backend tests](backend/testing.md) +* [Docker More Closely](DOCKER_MORE_CLOSELY.md) * [Deployment](https://github.com/Ocelot-Social-Community/Ocelot-Social-Deploy-Rebranding/blob/master/deployment/README.md) * [Contributing](CONTRIBUTING.md) * [Feature Specification](cypress/features.md) From 2bc09aceeb09a67b9f1eecc0942c04158971b6c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Mon, 18 Jul 2022 07:11:35 +0200 Subject: [PATCH 3/3] Rename Neo4j Docker in general image to 'neo4j-community:*' --- .github/workflows/publish.yml | 6 +++--- .github/workflows/test.yml | 4 ++-- docker-compose.override.yml | 2 +- docker-compose.test.yml | 2 +- docker-compose.yml | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1c7927665..56df65ea0 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -56,9 +56,9 @@ jobs: # NEO4J ################################################################## ########################################################################## - name: Neo4J | Build `community` image - run: docker build --target community -t "ocelotsocialnetwork/neo4j:latest" -t "ocelotsocialnetwork/neo4j:community" -t "ocelotsocialnetwork/neo4j:${VERSION}" -t "ocelotsocialnetwork/neo4j:${BUILD_VERSION}" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT neo4j/ + run: docker build --target community -t "ocelotsocialnetwork/neo4j-community:latest" -t "ocelotsocialnetwork/neo4j-community:${VERSION}" -t "ocelotsocialnetwork/neo4j-community:${BUILD_VERSION}" --build-arg BBUILD_DATE=$BUILD_DATE --build-arg BBUILD_VERSION=$BUILD_VERSION --build-arg BBUILD_COMMIT=$BUILD_COMMIT neo4j/ - name: Neo4J | Save docker image - run: docker save "ocelotsocialnetwork/neo4j" > /tmp/neo4j.tar + run: docker save "ocelotsocialnetwork/neo4j-community" > /tmp/neo4j.tar - name: Upload Artifact uses: actions/upload-artifact@v2 with: @@ -238,7 +238,7 @@ jobs: - name: login to dockerhub run: echo "${DOCKERHUB_TOKEN}" | docker login -u "${DOCKERHUB_USERNAME}" --password-stdin - name: Push neo4j - run: docker push --all-tags ocelotsocialnetwork/neo4j + run: docker push --all-tags ocelotsocialnetwork/neo4j-community - name: Push backend run: docker push --all-tags ocelotsocialnetwork/backend - name: Push webapp diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5dd385ad8..9564aa2f7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,8 +43,8 @@ jobs: ########################################################################## - name: Neo4J | Build `community` image run: | - docker build --target community -t "ocelotsocialnetwork/neo4j:community" neo4j/ - docker save "ocelotsocialnetwork/neo4j:community" > /tmp/neo4j.tar + docker build --target community -t "ocelotsocialnetwork/neo4j-community:test" neo4j/ + docker save "ocelotsocialnetwork/neo4j-community:test" > /tmp/neo4j.tar - name: Upload Artifact uses: actions/upload-artifact@v2 with: diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 15cf00e7a..ff2a398bb 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -38,7 +38,7 @@ services: # NEO4J ################################################ ######################################################## neo4j: - image: ocelotsocialnetwork/neo4j:development + image: ocelotsocialnetwork/neo4j-community:development ports: # Also expose the neo4j query browser - 7474:7474 diff --git a/docker-compose.test.yml b/docker-compose.test.yml index 973cf87cf..d11ecde54 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -27,7 +27,7 @@ services: # NEO4J ################################################ ######################################################## neo4j: - image: ocelotsocialnetwork/neo4j:community + image: ocelotsocialnetwork/neo4j-community:test #environment: # - NEO4J_dbms_connector_bolt_enabled=true # - NEO4J_dbms_connector_bolt_tls__level=OPTIONAL diff --git a/docker-compose.yml b/docker-compose.yml index d20bb6aec..863fb2c25 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -71,7 +71,7 @@ services: # NEO4J ################################################ ######################################################## neo4j: - image: ocelotsocialnetwork/neo4j:latest + image: ocelotsocialnetwork/neo4j-community:latest build: context: ./neo4j # community edition 👆🏼, because we have no enterprise licence 👇🏼 at the moment