diff --git a/deploy/docker-compose/base.yaml b/deploy/docker-compose/base.yaml index a3b74194f..8c1dd9529 100644 --- a/deploy/docker-compose/base.yaml +++ b/deploy/docker-compose/base.yaml @@ -47,17 +47,11 @@ services: networks: - intranet elements: - build: ../../elements + build: ../../frontend ports: - "9500:80" networks: - intranet - frontendsdk: - build: ../../frontend-sdk - ports: - - "9501:80" - networks: - - intranet mailslurper: image: marcopas/docker-mailslurper:latest ports: diff --git a/deploy/docker-compose/quickstart.yaml b/deploy/docker-compose/quickstart.yaml index 2966f697d..6d38ccafc 100644 --- a/deploy/docker-compose/quickstart.yaml +++ b/deploy/docker-compose/quickstart.yaml @@ -47,17 +47,11 @@ services: networks: - intranet elements: - build: ../../elements + build: ../../frontend ports: - "9500:80" networks: - intranet - frontendsdk: - build: ../../frontend-sdk - ports: - - "9501:80" - networks: - - intranet quickstart: build: ../../quickstart ports: @@ -66,7 +60,7 @@ services: - HANKO_URL=http://localhost:8000 - HANKO_URL_INTERNAL=http://hanko:8000 - HANKO_ELEMENT_URL=http://localhost:9500/element.hanko-auth.js - - HANKO_FRONTEND_SDK_URL=http://localhost:9501/sdk.umd.js + - HANKO_FRONTEND_SDK_URL=http://localhost:9500/sdk.umd.js networks: - intranet mailslurper: diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 000000000..aac52300f --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,31 @@ +FROM node:16.16-alpine as build + +WORKDIR /app +ENV PATH /app/node_modules/.bin:$PATH + +# frontend-sdk +COPY frontend-sdk/package.json frontend-sdk/ +COPY frontend-sdk/package-lock.json frontend-sdk/ + +WORKDIR /app/frontend-sdk +RUN npm ci --silent +COPY frontend-sdk/ ./ +RUN npm run build + + +# elements +WORKDIR /app/elements +COPY elements/package.json ./ +COPY elements/package-lock.json ./ + +RUN npm ci +COPY ./elements ./ +RUN npm run build + +FROM nginx:stable-alpine +COPY --from=build /app/elements/dist/element.hanko-auth.js /usr/share/nginx/html +COPY --from=build /app/frontend-sdk/dist/sdk.* /usr/share/nginx/html + +COPY elements/nginx/default.conf /etc/nginx/conf.d/default.conf +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] diff --git a/frontend/Dockerfile.debug b/frontend/Dockerfile.debug new file mode 100644 index 000000000..86d3330f1 --- /dev/null +++ b/frontend/Dockerfile.debug @@ -0,0 +1,31 @@ +FROM node:16.16-alpine as build + +WORKDIR /app +ENV PATH /app/node_modules/.bin:$PATH + +# frontend-sdk +COPY frontend-sdk/package.json frontend-sdk/ +COPY frontend-sdk/package-lock.json frontend-sdk/ + +WORKDIR /app/frontend-sdk +RUN npm ci --silent +COPY frontend-sdk/ ./ +RUN npm run build + + +# elements +WORKDIR /app/elements +COPY elements/package.json ./ +COPY elements/package-lock.json ./ + +RUN npm ci +COPY ./elements ./ +RUN npm run build:dev + +FROM nginx:stable-alpine +COPY --from=build /app/elements/dist/element.hanko-auth.js /usr/share/nginx/html +COPY --from=build /app/frontend-sdk/dist/sdk.* /usr/share/nginx/html + +COPY elements/nginx/default.conf /etc/nginx/conf.d/default.conf +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] diff --git a/frontend/elements/Dockerfile b/frontend/elements/Dockerfile index b1c9ba5d9..b528a4617 100644 --- a/frontend/elements/Dockerfile +++ b/frontend/elements/Dockerfile @@ -3,8 +3,16 @@ FROM node:16.16-alpine as build WORKDIR /app ENV PATH /app/node_modules/.bin:$PATH -COPY package.json ./ -COPY package-lock.json ./ +# Build SDK dependency +COPY ../frontend-sdk/package.json ../frontend-sdk/ +COPY ../frontend-sdk/package-lock.json ../frontend-sdk/ + +RUN npm ci --silent ../frontend-sdk +COPY ../frontend-sdk/ ../frontend-sdk +RUN npm run build ../frontend-sdk + +COPY elements/package.json ./ +COPY elements/package-lock.json ./ RUN npm ci --silent COPY . ./ @@ -13,6 +21,6 @@ RUN npm run build FROM nginx:stable-alpine COPY --from=build /app/dist/element.hanko-auth.js /usr/share/nginx/html -COPY nginx/default.conf /etc/nginx/conf.d/default.conf +COPY elements/nginx/default.conf /etc/nginx/conf.d/default.conf EXPOSE 80 CMD ["nginx", "-g", "daemon off;"] diff --git a/frontend/elements/package-lock.json b/frontend/elements/package-lock.json index 3e89211ac..c59133799 100644 --- a/frontend/elements/package-lock.json +++ b/frontend/elements/package-lock.json @@ -7,10 +7,13 @@ "": { "name": "@teamhanko/hanko-elements", "version": "0.0.12-alpha", + "bundleDependencies": [ + "@teamhanko/hanko-frontend-sdk" + ], "license": "MIT", "dependencies": { "@denysvuika/preact-translate": "^0.4.1", - "@teamhanko/hanko-frontend-sdk": "^0.0.8-alpha", + "@teamhanko/hanko-frontend-sdk": "file:../frontend-sdk", "classnames": "^2.3.2", "preact": "^10.10.1", "preact-custom-element": "^4.2.1" @@ -36,6 +39,32 @@ "webpack-cli": "^4.9.2" } }, + "../frontend-sdk": { + "version": "0.0.8-alpha", + "license": "MIT", + "dependencies": { + "@types/js-cookie": "^3.0.2" + }, + "devDependencies": { + "@github/webauthn-json": "^2.0.1", + "@types/jest": "^29.0.3", + "@typescript-eslint/eslint-plugin": "^5.40.1", + "better-docs": "^2.7.2", + "eslint": "^8.27.0", + "eslint-config-google": "^0.14.0", + "eslint-config-preact": "^1.3.0", + "eslint-config-prettier": "^8.5.0", + "eslint-plugin-prettier": "^4.0.0", + "eslint-plugin-promise": "^6.1.1", + "jest": "^29.2.0", + "jest-environment-jsdom": "^29.2.2", + "js-cookie": "^3.0.1", + "microbundle": "^0.15.1", + "ts-jest": "^29.0.3", + "ts-loader": "^9.4.1", + "typescript": "^4.8.4" + } + }, "node_modules/@ampproject/remapping": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.0.tgz", @@ -1350,12 +1379,8 @@ } }, "node_modules/@teamhanko/hanko-frontend-sdk": { - "version": "0.0.8-alpha", - "resolved": "https://registry.npmjs.org/@teamhanko/hanko-frontend-sdk/-/hanko-frontend-sdk-0.0.8-alpha.tgz", - "integrity": "sha512-fMLsKh6gXfEUZeQiXEZv83ZsNqOYJ1s6X7GL8n5aGsAeQUPbf2Fxsg/7+w7N9wLT7fXannPA4VOag74sSaEC/w==", - "dependencies": { - "@types/js-cookie": "^3.0.2" - } + "resolved": "../frontend-sdk", + "link": true }, "node_modules/@tootallnate/once": { "version": "1.1.2", @@ -1473,11 +1498,6 @@ "@types/istanbul-lib-report": "*" } }, - "node_modules/@types/js-cookie": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@types/js-cookie/-/js-cookie-3.0.2.tgz", - "integrity": "sha512-6+0ekgfusHftJNYpihfkMu8BWdeHs9EOJuGcSofErjstGPfPGEu9yTu4t460lTzzAMl2cM5zngQJqPMHbbnvYA==" - }, "node_modules/@types/json-schema": { "version": "7.0.11", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", @@ -10434,11 +10454,26 @@ } }, "@teamhanko/hanko-frontend-sdk": { - "version": "0.0.8-alpha", - "resolved": "https://registry.npmjs.org/@teamhanko/hanko-frontend-sdk/-/hanko-frontend-sdk-0.0.8-alpha.tgz", - "integrity": "sha512-fMLsKh6gXfEUZeQiXEZv83ZsNqOYJ1s6X7GL8n5aGsAeQUPbf2Fxsg/7+w7N9wLT7fXannPA4VOag74sSaEC/w==", + "version": "file:../frontend-sdk", "requires": { - "@types/js-cookie": "^3.0.2" + "@github/webauthn-json": "^2.0.1", + "@types/jest": "^29.0.3", + "@types/js-cookie": "^3.0.2", + "@typescript-eslint/eslint-plugin": "^5.40.1", + "better-docs": "^2.7.2", + "eslint": "^8.27.0", + "eslint-config-google": "^0.14.0", + "eslint-config-preact": "^1.3.0", + "eslint-config-prettier": "^8.5.0", + "eslint-plugin-prettier": "^4.0.0", + "eslint-plugin-promise": "^6.1.1", + "jest": "^29.2.0", + "jest-environment-jsdom": "^29.2.2", + "js-cookie": "^3.0.1", + "microbundle": "^0.15.1", + "ts-jest": "^29.0.3", + "ts-loader": "^9.4.1", + "typescript": "^4.8.4" } }, "@tootallnate/once": { @@ -10554,11 +10589,6 @@ "@types/istanbul-lib-report": "*" } }, - "@types/js-cookie": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@types/js-cookie/-/js-cookie-3.0.2.tgz", - "integrity": "sha512-6+0ekgfusHftJNYpihfkMu8BWdeHs9EOJuGcSofErjstGPfPGEu9yTu4t460lTzzAMl2cM5zngQJqPMHbbnvYA==" - }, "@types/json-schema": { "version": "7.0.11", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz",