diff --git a/.github/workflows/build-and-deploy-api-gateway.yml b/.github/workflows/build-and-deploy-api-gateway.yml index 001cd833..dff0ec02 100644 --- a/.github/workflows/build-and-deploy-api-gateway.yml +++ b/.github/workflows/build-and-deploy-api-gateway.yml @@ -31,7 +31,7 @@ jobs: ~/.cache/Cypress # needed for the Cypress binary key: npm-dependencies-${{ hashFiles('package.json') }} - name: Build base image - run: npm run docker-base + run: npm run docker-base-linux - name: Tag base image run: docker tag linkerry/base registry.digitalocean.com/linkerry/base:latest - name: Install doctl diff --git a/.github/workflows/build-and-deploy-web.yml b/.github/workflows/build-and-deploy-web.yml index 3327c96d..49514814 100644 --- a/.github/workflows/build-and-deploy-web.yml +++ b/.github/workflows/build-and-deploy-web.yml @@ -32,7 +32,7 @@ jobs: ~/.cache/Cypress # needed for the Cypress binary key: npm-dependencies-${{ hashFiles('package.json') }} - name: Build base image - run: npm run docker-base + run: npm run docker-base-linux - name: Tag base image run: docker tag linkerry/base registry.digitalocean.com/linkerry/base:latest diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index d2a1b996..a3ae5036 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -35,7 +35,7 @@ jobs: ~/.cache/Cypress # needed for the Cypress binary key: npm-dependencies-${{ hashFiles('package.json') }} # - name: Build base image - # run: npm run docker-base + # run: npm run docker-base-linux # - name: Tag base image # run: # docker tag linkerry/base registry.digitalocean.com/linkerry/base:latest diff --git a/.gitignore b/.gitignore index f9be77dd..7ceb1986 100644 --- a/.gitignore +++ b/.gitignore @@ -47,4 +47,5 @@ Thumbs.db docs/examples/** -.nx/cache \ No newline at end of file +.nx/cache +.verdacio/prod/htpasswd diff --git a/.npmrc b/.npmrc index 19be10eb..74a51cee 100644 --- a/.npmrc +++ b/.npmrc @@ -1,2 +1,4 @@ strict-peer-dependencies=false auto-install-peers=true +ignore-scripts=true +# registry=http://localhost:4873 diff --git a/.verdaccio/prod/config.yml b/.verdaccio/prod/config.yml new file mode 100644 index 00000000..cbdc4c19 --- /dev/null +++ b/.verdaccio/prod/config.yml @@ -0,0 +1,64 @@ +# path to a directory with all packages +storage: ../tmp/local-registry/storage + +# a list of other known repositories we can talk to +uplinks: + npmjs: + url: https://registry.npmjs.org/ + maxage: 60m + +auth: + htpasswd: + file: ./htpasswd + max_users: 1 + +security: + api: + jwt: + sign: + expiresIn: 365d + notBefore: 1 + web: + sign: + expiresIn: 7d + +packages: + '@linkerry/*': + access: $authenticated + publish: $authenticated + '@*/*': + access: $authenticated + publish: $authenticated + proxy: npmjs + '**': + access: $authenticated + publish: $authenticated + proxy: npmjs + # '@linkerry/*': + # # scoped packages + # # you can specify usernames/groupnames (depending on your auth plugin) + # # and three keywords: "$all", "$anonymous", "$authenticated" + # access: '$authenticated' + # publish: '$authenticated' + # '**': + # proxy: npmjs + # access: '$authenticated' + # publish: '$authenticated' + # # '**': + # # # give all users (including non-authenticated users) full access + # # # because it is a local registry + # # access: $all + # # publish: $all + # # unpublish: $all + + # # # if package is not available locally, proxy requests to npm registry + # # proxy: npmjs + +# log settings +logs: + type: stdout + format: pretty + level: warn + +publish: + allow_offline: true # set offline to true to allow publish offline diff --git a/.verdaccio/prod/docker-compose.verdacio.yml b/.verdaccio/prod/docker-compose.verdacio.yml new file mode 100644 index 00000000..3bff0d4f --- /dev/null +++ b/.verdaccio/prod/docker-compose.verdacio.yml @@ -0,0 +1,27 @@ +version: '3.9' + +services: + verdaccio: + image: verdaccio/verdaccio + container_name: verdaccio + ports: + - ${VIRTUAL_PORT}:${VIRTUAL_PORT} + env_file: + - .env + environment: + - VIRTUAL_HOST=${VIRTUAL_HOST} + - LETSENCRYPT_HOST=${LETSENCRYPT_HOST} + - LETSENCRYPT_EMAIL=anteqkois@gmail.com + - VIRTUAL_PORT=${VIRTUAL_PORT} + volumes: + - './storage:/verdaccio/storage' + - './conf:/verdaccio/conf' + +volumes: + verdaccio: + driver: local + +networks: + default: + external: + name: ${NETWORK:-proxy} diff --git a/.verdaccio/prod/htpasswd b/.verdaccio/prod/htpasswd new file mode 100644 index 00000000..e69de29b diff --git a/apps/api-gateway/docker-compose.prod.yml b/apps/api-gateway/docker-compose.prod.yml index b66ff688..8d12a12a 100644 --- a/apps/api-gateway/docker-compose.prod.yml +++ b/apps/api-gateway/docker-compose.prod.yml @@ -6,7 +6,7 @@ services: env_file: - .env environment: - - VIRTUAL_HOST=${PORT_API_GATEWAY} + - VIRTUAL_HOST=${VIRTUAL_HOST} - LETSENCRYPT_HOST=${LETSENCRYPT_HOST} - LETSENCRYPT_EMAIL=anteqkois@gmail.com - VIRTUAL_PORT=${VIRTUAL_PORT} diff --git a/apps/web/Dockerfile b/apps/web/Dockerfile index 836f897a..db89317a 100644 --- a/apps/web/Dockerfile +++ b/apps/web/Dockerfile @@ -15,7 +15,11 @@ FROM node:lts-alpine AS runner WORKDIR /app COPY --from=builder /app/builder/apps/web/.next/standalone ./ + +# https://nextjs.org/docs/pages/api-reference/next-config-js/output#automatically-copying-traced-files +# NextJS does not copy the public or .next/static folders by default as these should ideally be handled by a CDN instead, although these folders can be copied to the standalone/public and standalone/.next/static folders manually, after which server.js file will serve these automatically. COPY --from=builder /app/builder/apps/web/.next/static ./.next/static +COPY --from=builder /app/builder/apps/web/public ./public ENV PORT 3000 ENV NODE_ENV=$NODE_ENV diff --git a/apps/web/next.config.js b/apps/web/next.config.js index d8fcdc70..498b4c37 100644 --- a/apps/web/next.config.js +++ b/apps/web/next.config.js @@ -2,6 +2,7 @@ // eslint-disable-next-line @typescript-eslint/no-var-requires const { composePlugins, withNx } = require('@nx/next'); +const path = require('path'); /** * @type {import('@nx/next/plugins/with-nx').WithNxOptions} @@ -34,6 +35,7 @@ const nextConfig = { ], }, output: "standalone", + // outputFileTracingRoot: path.join(__dirname, '../../'), experimental: { missingSuspenseWithCSRBailout: false, }, diff --git a/docs/devops/clean-linux.md b/docs/devops/clean-linux.md index 39122523..01c8307e 100644 --- a/docs/devops/clean-linux.md +++ b/docs/devops/clean-linux.md @@ -1,6 +1,6 @@ rm -rf ~/.cache du -sh /var/log - rm -rf ~/tmp +rm -rf ~/tmp apt-get autoremove sudo du -sh /var/cache/apt sudo journalctl --vacuum-time=3d diff --git a/docs/devops/docker-prune.md b/docs/devops/docker-prune.md new file mode 100644 index 00000000..e69de29b diff --git a/docs/npm/set-registry.md b/docs/npm-registry/set-registry.md similarity index 100% rename from docs/npm/set-registry.md rename to docs/npm-registry/set-registry.md diff --git a/docs/npm-registry/setup-verdacio.md b/docs/npm-registry/setup-verdacio.md new file mode 100644 index 00000000..e69de29b diff --git a/package.json b/package.json index 8969a0f8..62395fb9 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,8 @@ "registry-and-publish": "sleep 3 && make publish-connectors & npx nx local-registry", "ngrok": "ngrok http --domain=fairly-winning-chamois.ngrok-free.app 3001", "stripe": "stripe listen --forward-to localhost:3001/api/v1/stripe/webhook", - "docker-base": "docker build . -t linkerry/base:latest --platform=linux/amd64", + "docker-base-linux": "docker build . -t linkerry/base:latest --platform=linux/amd64", + "docker-base": "docker build . -t linkerry/base:latest", "docker-api": "docker compose -f ./apps/api-gateway/docker-compose.local.yml up -d", "docker-web": "docker compose -f ./apps/web/docker-compose.local.yml up -d" },