From 3199d74d427a224e51298a48de96bcce3e6419f9 Mon Sep 17 00:00:00 2001 From: Gerald Baulig Date: Fri, 17 May 2024 12:12:13 +0200 Subject: [PATCH] refactor(docker): more build args, better env:token, remove countries form demoshop --- Dockerfile | 8 ++- buildImage.bash | 2 + .../demo-shop/data/seed-data/countries.yaml | 59 ------------------- package.json | 2 +- 4 files changed, 8 insertions(+), 63 deletions(-) delete mode 100644 datasets/demo-shop/data/seed-data/countries.yaml diff --git a/Dockerfile b/Dockerfile index f275bef..f8f988b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,11 @@ ### Base FROM node:20.8.0-alpine3.18 as base -ENV DB_IMPORT_ENTRY="http://facade-srv:5000/graphql" -ENV OBJECT_IMPORT_ENDPOINT="http://facade-srv:5000/graphql" +ARG DB_IMPORT_ENTRY=http://facade-srv:5000/graphql +ARG OBJECT_IMPORT_ENDPOINT=http://facade-srv:5000/graphql + +ENV DB_IMPORT_ENTRY=$DB_IMPORT_ENTRY +ENV OBJECT_IMPORT_ENDPOINT=$OBJECT_IMPORT_ENDPOINT USER node ARG APP_HOME=/home/node/data @@ -12,5 +15,4 @@ COPY --chown=node:node datasets ./datasets COPY --chown=node:node *json *.js ./ RUN npm ci - CMD ["sleep", "infinity"] \ No newline at end of file diff --git a/buildImage.bash b/buildImage.bash index e10b730..d1eee87 100755 --- a/buildImage.bash +++ b/buildImage.bash @@ -7,4 +7,6 @@ DOCKER_BUILDKIT=1 docker build \ -f ./Dockerfile \ --cache-from restorecommerce/$SERVICE_NAME \ --build-arg APP_HOME=/home/node/$SERVICE_NAME \ + --build-arg DB_IMPORT_ENTRY=http://facade-srv:5000/graphql \ + --build-arg OBJECT_IMPORT_ENDPOINT=http://facade-srv:5000/graphql \ . diff --git a/datasets/demo-shop/data/seed-data/countries.yaml b/datasets/demo-shop/data/seed-data/countries.yaml deleted file mode 100644 index b4de61d..0000000 --- a/datasets/demo-shop/data/seed-data/countries.yaml +++ /dev/null @@ -1,59 +0,0 @@ ---- - id: restorecommerce-demo-country-germany - name: Germany - countryCode: DE - geographicalName: Germany - economicAreas: - - EEA - meta: - modifiedBy: "" - owners: - - id: urn:restorecommerce:acs:names:ownerIndicatoryEntity - value: urn:restorecommerce:acs:model:organization.Organization - attributes: - - id: urn:restorecommerce:acs:names:ownerInstance - value: restorecommerce-demo-root-organization ---- - id: restorecommerce-demo-country-switzerland - name: Switzerland - countryCode: CH - geographicalName: Switzerland - economicAreas: [] - meta: - modifiedBy: "" - owners: - - id: urn:restorecommerce:acs:names:ownerIndicatoryEntity - value: urn:restorecommerce:acs:model:organization.Organization - attributes: - - id: urn:restorecommerce:acs:names:ownerInstance - value: restorecommerce-demo-root-organization ---- - id: restorecommerce-demo-country-belgium - name: Belgium - countryCode: BE - geographicalName: Belgium - economicAreas: - - EEA - meta: - modifiedBy: "" - owners: - - id: urn:restorecommerce:acs:names:ownerIndicatoryEntity - value: urn:restorecommerce:acs:model:organization.Organization - attributes: - - id: urn:restorecommerce:acs:names:ownerInstance - value: restorecommerce-demo-root-organization ---- - id: restorecommerce-demo-country-france - name: France - countryCode: FR - geographicalName: France - economicAreas: - - EEA - meta: - modifiedBy: "" - owners: - - id: urn:restorecommerce:acs:names:ownerIndicatoryEntity - value: urn:restorecommerce:acs:model:organization.Organization - attributes: - - id: urn:restorecommerce:acs:names:ownerInstance - value: restorecommerce-demo-root-organization diff --git a/package.json b/package.json index 4a5aea8..71573d4 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ }, "scripts": { "build": "tsc -d -P tsconfig.objects.json", - "env:token": "echo $(docker logs --tail 2000 restorecommerce_facade_srv 2> /dev/null | grep 'Bootstrap API Key is:' | awk '{print \"\rACCESS_TOKEN=\"$7}') > .env && cat .env", + "env:token": "echo $(docker logs --tail 2000 restorecommerce_facade_srv 2> /dev/null | grep 'Bootstrap API Key is:' | tail -1 | awk '{print \"ACCESS_TOKEN=\"$7}') > .env && cat .env", "import": "npm-run-all import:system import:demoshop", "import:system": "npm-run-all import:system:master import:system:identity import:system:rules import:system:extra", "import:system:master": "node dataset.js import -d system -j master",