Skip to content

Commit

Permalink
chore(deploy): fix nextjs deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
anteqkois committed May 18, 2024
1 parent 70e25b1 commit 72ba1b1
Show file tree
Hide file tree
Showing 16 changed files with 108 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-deploy-api-gateway.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-and-deploy-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ Thumbs.db

docs/examples/**

.nx/cache
.nx/cache
.verdacio/prod/htpasswd
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
strict-peer-dependencies=false
auto-install-peers=true
ignore-scripts=true
# registry=http://localhost:4873
64 changes: 64 additions & 0 deletions .verdaccio/prod/config.yml
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions .verdaccio/prod/docker-compose.verdacio.yml
Original file line number Diff line number Diff line change
@@ -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}
- [email protected]
- VIRTUAL_PORT=${VIRTUAL_PORT}
volumes:
- './storage:/verdaccio/storage'
- './conf:/verdaccio/conf'

volumes:
verdaccio:
driver: local

networks:
default:
external:
name: ${NETWORK:-proxy}
Empty file added .verdaccio/prod/htpasswd
Empty file.
2 changes: 1 addition & 1 deletion apps/api-gateway/docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
env_file:
- .env
environment:
- VIRTUAL_HOST=${PORT_API_GATEWAY}
- VIRTUAL_HOST=${VIRTUAL_HOST}
- LETSENCRYPT_HOST=${LETSENCRYPT_HOST}
- [email protected]
- VIRTUAL_PORT=${VIRTUAL_PORT}
Expand Down
4 changes: 4 additions & 0 deletions apps/web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions apps/web/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -34,6 +35,7 @@ const nextConfig = {
],
},
output: "standalone",
// outputFileTracingRoot: path.join(__dirname, '../../'),
experimental: {
missingSuspenseWithCSRBailout: false,
},
Expand Down
2 changes: 1 addition & 1 deletion docs/devops/clean-linux.md
Original file line number Diff line number Diff line change
@@ -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
Empty file added docs/devops/docker-prune.md
Empty file.
File renamed without changes.
Empty file.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down

0 comments on commit 72ba1b1

Please sign in to comment.