diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..a76248d4c0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +FROM debian:latest AS artifact +ENV ZITADEL_ARGS= +ARG TARGETPLATFORM + +RUN apt-get update && apt-get install ca-certificates -y + +COPY entrypoint.sh /app/entrypoint.sh +COPY zitadel /app/zitadel + +RUN useradd -s "" --home / zitadel && \ + chown zitadel /app/zitadel && \ + chmod +x /app/zitadel && \ + chown zitadel /app/entrypoint.sh && \ + chmod +x /app/entrypoint.sh + +WORKDIR /app +ENV PATH="/app:${PATH}" + +USER zitadel +ENTRYPOINT ["/app/entrypoint.sh"] + +FROM scratch AS final +ARG TARGETPLATFORM + +COPY --from=artifact /etc/passwd /etc/passwd +COPY --from=artifact /etc/ssl/certs /etc/ssl/certs +COPY --from=artifact /app/zitadel /app/zitadel + +HEALTHCHECK NONE +EXPOSE 8080 + +USER zitadel +ENTRYPOINT ["/app/zitadel"] \ No newline at end of file diff --git a/apps/console/Dockerfile b/apps/console/Dockerfile new file mode 100644 index 0000000000..d81bc0171e --- /dev/null +++ b/apps/console/Dockerfile @@ -0,0 +1,11 @@ + +FROM nginx:1.29.0 +RUN touch /var/run/nginx.pid && \ + chown -R nginx:nginx /var/cache/nginx /var/run/nginx.pid +USER nginx +COPY --chown=nginx:nginx nginx.conf /etc/nginx/nginx.conf +# TODO Needs work to be configured for the console app +COPY --chown=nginx:nginx dist/console /usr/share/nginx/html +EXPOSE 3001 +ENTRYPOINT ["nginx", "-c", "/etc/nginx/nginx.conf"] +CMD ["-g", "daemon off;"] \ No newline at end of file diff --git a/apps/console/nginx.conf b/apps/console/nginx.conf new file mode 100644 index 0000000000..def67e3597 --- /dev/null +++ b/apps/console/nginx.conf @@ -0,0 +1,69 @@ +worker_processes auto; + +pid /tmp/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + # Logging + access_log off; + error_log /dev/stderr warn; + + # Performance + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + keepalive_requests 1000; + + # Compression + gzip on; + gzip_vary on; + gzip_proxied any; + gzip_min_length 256; + gzip_comp_level 6; + gzip_types + text/plain + text/css + text/xml + text/javascript + application/javascript + application/x-javascript + application/json + application/xml + application/xml+rss + font/ttf + font/otf + image/svg+xml; + + server { + listen 3001; + server_name localhost; + + root /usr/share/nginx/html; + index index.html; + + # Angular Routing + location / { + try_files $uri $uri/ /index.html; + } + + # Static Assets Caching + location ~* \.(?:ico|css|js|gif|jpe?g|png|woff2?|eot|ttf|svg|map)$ { + expires 1y; + access_log off; + add_header Cache-Control "public, immutable"; + } + + # Optional: Explicit asset route + location /assets/ { + expires 1y; + add_header Cache-Control "public, immutable"; + } + } +} \ No newline at end of file diff --git a/apps/console/package.json b/apps/console/package.json index 8455785d27..807d7ba1d0 100644 --- a/apps/console/package.json +++ b/apps/console/package.json @@ -11,15 +11,15 @@ "lint:check:prettier": "prettier --check src", "lint:fix": "prettier --write src", "generate": "pnpm exec buf generate ../../proto --include-imports --include-wkt", - "clean": "rm -rf dist .angular .turbo node_modules src/app/proto/generated" + "clean": "rm -rf dist .angular node_modules src/app/proto/generated" }, "nx": { + "release": { + "docker": { + "repositoryName": "zitadel/console" + } + }, "targets": { - "release": { - "docker": { - "repositoryName": "zitadel/console" - } - }, "generate": { "outputs": [ "{projectRoot}/src/app/proto/generated/**" @@ -33,10 +33,21 @@ "generate", "@zitadel/client:build" ] + }, + "docker:build": { + "dependsOn": ["build"] + }, + "docker:run": { + "options": { + "args": [ + "-p", + "3001:3001" + ] + } } } }, - "dependencies": { + "dependencies": { "@angular/animations": "^16.2.12", "@angular/cdk": "^16.2.14", "@angular/common": "^16.2.12", diff --git a/apps/login/.dockerignore b/apps/login/.dockerignore deleted file mode 100644 index 4e64fd495f..0000000000 --- a/apps/login/.dockerignore +++ /dev/null @@ -1,21 +0,0 @@ -* - -!constants -!scripts -!src -!public -!locales -!next.config.mjs -!next-env-vars.d.ts -!next-env.d.ts -!tailwind.config.js -!tsconfig.json -!package.json -!pnpm-lock.yaml - -**/*.md -**/*.png -**/node_modules -**/.turbo -**/*.test.ts -**/*.test.tsx \ No newline at end of file diff --git a/apps/login/Dockerfile b/apps/login/Dockerfile index 5ee982ec1a..b3db5b3063 100644 --- a/apps/login/Dockerfile +++ b/apps/login/Dockerfile @@ -9,16 +9,15 @@ ENV NODE_ENV=production RUN addgroup --system --gid 1001 nodejs RUN adduser --system --uid 1001 nextjs -COPY public ./public -COPY .next/standalone ./ -COPY .next/static ./.next/static -RUN ls .next/static +COPY --chown=nextjs:nodejs public ./public +COPY --chown=nextjs:nodejs .next/standalone/ ./ +COPY --chown=nextjs:nodejs .next/static ./.next/static USER nextjs -EXPOSE 3000 +EXPOSE 3002 -ENV PORT=3000 +ENV PORT=3002 ENV HOSTNAME="0.0.0.0" -CMD ["node", "server.js"] \ No newline at end of file +CMD ["node", "./apps/login/server.js"] \ No newline at end of file diff --git a/apps/login/package.json b/apps/login/package.json index de0de03daa..ec9c4f373a 100644 --- a/apps/login/package.json +++ b/apps/login/package.json @@ -58,6 +58,19 @@ "dependsOn": [ "@zitadel/client#build" ] + }, + "docker:build": { + "dependsOn": [ + "build:login:standalone" + ] + }, + "docker:run": { + "options": { + "args": [ + "-p", + "3002:3002" + ] + } } } }, diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000000..77f6d5f931 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +case $@ in + sh*) + ${@:3} + ;; + bash*) + ${@:5} + ;; + *) + if [[ ! -z "$@" ]] + then + ZITADEL_ARGS="$@" + fi + /app/zitadel ${ZITADEL_ARGS} + ;; +esac \ No newline at end of file diff --git a/hodor/package.json b/hodor/package.json new file mode 100644 index 0000000000..d6a8b8d016 --- /dev/null +++ b/hodor/package.json @@ -0,0 +1,53 @@ +{ + "packageManager": "pnpm@9.1.2+sha256.19c17528f9ca20bd442e4ca42f00f1b9808a9cb419383cd04ba32ef19322aba7", + "private": true, + "name": "@zitadel/api", + "scripts": { + "build": "make compile" + }, + "nx": { + "release": { + "docker": { + "repositoryName": "zitadel/zitadel" + } + }, + "targets": { + "build": { + "outputs": [ + "{workspaceRoot}/zitadel" + ], + "dependsOn": [ + "@zitadel/console:build" + ] + }, + "docker:build": { + "dependsOn": [ + "build" + ] + }, + "docker:run": { + "options": { + "args": [ + "-p", + "3000:3000" + ] + } + } + } + }, + "pnpm": { + "overrides": { + "@typescript-eslint/parser": "^8.35.1", + "@zitadel/client": "workspace:*", + "@zitadel/proto": "workspace:*" + } + }, + "devDependencies": { + "@bufbuild/buf": "^1.55.1", + "@changesets/cli": "^2.29.5", + "@devcontainers/cli": "^0.80.0", + "@nx/docker": "21.4.0-beta.5", + "nx": "21.4.0-beta.5", + "sass": "1.64.1" + } +} diff --git a/nx.json b/nx.json index 4e79c79e65..01830012af 100644 --- a/nx.json +++ b/nx.json @@ -4,7 +4,7 @@ "releaseTagPattern": "release/{projectName}/{version}", "groups": { "test": { - "projects": ["@zitadel/login", "@zitadel/console"], + "projects": ["@zitadel/login", "@zitadel/console", "@zitadel/api"], "projectsRelationship": "fixed", "docker": { "skipVersionActions": true, diff --git a/package.json b/package.json index d65d7a03e7..b475ca27a7 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,11 @@ "build": "make compile" }, "nx": { + "release": { + "docker": { + "repositoryName": "zitadel/zitadel" + } + }, "targets": { "build": { "outputs": [ @@ -14,6 +19,25 @@ "dependsOn": [ "@zitadel/console:build" ] + }, + "docker:build": { + "dependsOn": [ + "build" + ], + "options": { + "push": false, + "tags": [ + "zitadel/zitadel:latest" + ] + } + }, + "docker:run": { + "options": { + "args": [ + "-p", + "3000:3000" + ] + } } } }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 07f3938eb5..d023841894 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -591,6 +591,27 @@ importers: specifier: ^13.13.3 version: 13.17.0 + hodor: + devDependencies: + '@bufbuild/buf': + specifier: ^1.55.1 + version: 1.55.1 + '@changesets/cli': + specifier: ^2.29.5 + version: 2.29.5 + '@devcontainers/cli': + specifier: ^0.80.0 + version: 0.80.0 + '@nx/docker': + specifier: 21.4.0-beta.5 + version: 21.4.0-beta.5(nx@21.4.0-beta.5(@swc/core@1.13.3)) + nx: + specifier: 21.4.0-beta.5 + version: 21.4.0-beta.5(@swc/core@1.13.3) + sass: + specifier: 1.64.1 + version: 1.64.1 + packages/zitadel-client: dependencies: '@bufbuild/protobuf': diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 58f1cc709e..31417c906f 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -3,3 +3,4 @@ packages: - "e2e" - "packages/*" - "apps/*" + - "hodor"