-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from safeinsights/dockerize
dockerize and deploy
- Loading branch information
Showing
29 changed files
with
1,548 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# .dockerignore | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# local env files | ||
.env*.local | ||
|
||
# vercel | ||
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"target": { | ||
"mgmnt-app": { | ||
"cache-from": ["type=gha,scope=safeinsights/management-app/mgmnt-app"], | ||
"cache-to": ["type=gha,mode=max,scope=safeinsights/management-app/mgmnt-app"], | ||
"output": ["type=docker"] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
FROM node:21-bookworm AS base | ||
|
||
WORKDIR /app | ||
|
||
|
||
COPY package.json package-lock.json ./ | ||
|
||
RUN npm install | ||
|
||
RUN npx playwright install | ||
RUN npx playwright install-deps | ||
|
||
#COPY .gitignore .editorconfig next.config.mjs tsconfig.json kysely.config.ts .eslintrc.json .prettierrc.json . | ||
|
||
# Next.js collects completely anonymous telemetry data about general usage. Learn more here: https://nextjs.org/telemetry | ||
# Uncomment the following line to disable telemetry at run time | ||
ENV NEXT_TELEMETRY_DISABLED=1 | ||
|
||
# for deploting the build version | ||
|
||
# RUN bun next build | ||
# and | ||
# CMD bun next start | ||
|
||
# OR for sart Next.js in development, comment above two lines and uncomment below line | ||
|
||
CMD ["./bin/docker-dev-init"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
FROM public.ecr.aws/docker/library/node:21-bookworm-slim AS base | ||
|
||
# add aws-lambda-adapter extension | ||
COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.8.4 /lambda-adapter /opt/extensions/lambda-adapter | ||
|
||
RUN mkdir /app | ||
WORKDIR /app | ||
|
||
FROM base AS npm | ||
|
||
COPY package.json package-lock.json* ./ | ||
RUN npm ci | ||
|
||
FROM base AS builder | ||
|
||
COPY . . | ||
|
||
COPY --from=npm /app/node_modules ./node_modules | ||
|
||
# disables nextjs telemetry during the build. | ||
ENV NEXT_TELEMETRY_DISABLED=1 | ||
ENV NODE_ENV=production | ||
ENV AWS_LWA_ENABLE_COMPRESSION=true | ||
|
||
RUN npm run build | ||
|
||
WORKDIR /app | ||
|
||
FROM base AS release | ||
|
||
ENV NODE_ENV=production | ||
ENV PORT=8080 | ||
EXPOSE $PORT | ||
|
||
COPY ./bin/lambda-server.sh ./run.sh | ||
|
||
# copy static files and images from build | ||
COPY --from=builder /app/public ./public | ||
COPY --from=builder /app/package.json ./package.json | ||
COPY --from=builder /app/.next/standalone ./ | ||
COPY --from=builder /app/.next/static ./.next/static | ||
RUN ln -s /tmp/cache ./.next/cache | ||
|
||
|
||
CMD ["./run.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
# this file is the entrypoint for the Dockerfile.dev | ||
# and is used for local development | ||
|
||
set -e | ||
|
||
npm install | ||
|
||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" | ||
|
||
$SCRIPT_DIR/migrate-dev-db | ||
|
||
npm run dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
[ ! -d '/tmp/cache' ] && mkdir -p /tmp/cache | ||
|
||
exec node server.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
TYPES=src/database/types.ts | ||
|
||
npx kysely migrate:up | ||
|
||
npx kysely-codegen --camel-case --dialect postgres --out-file $TYPES | ||
npx prettier --write $TYPES | ||
npx eslint --fix $TYPES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
services: | ||
postgres: | ||
image: 'postgres:16' | ||
volumes: | ||
- pgdata:/var/lib/postgresql/data | ||
networks: | ||
- mgmnt-app | ||
environment: | ||
- POSTGRES_USER=mgmnt | ||
- POSTGRES_PASSWORD=mgmntpass | ||
- POSTGRES_DB=mgmnt_dev | ||
healthcheck: | ||
test: ['CMD-SHELL', 'pg_isready -U mgmnt -d mgmnt_dev'] | ||
interval: 10s | ||
retries: 5 | ||
start_period: 30s | ||
timeout: 10s | ||
mgmnt-app: | ||
container_name: mgmnt-app | ||
depends_on: | ||
postgres: | ||
condition: service_healthy | ||
restart: true | ||
environment: | ||
- CI=$CI | ||
- NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=$NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY | ||
- CLERK_SECRET_KEY=$CLERK_SECRET_KEY | ||
- E2E_CLERK_USER_USERNAME=$E2E_CLERK_USER_USERNAME | ||
- E2E_CLERK_USER_PASSWORD=$E2E_CLERK_USER_PASSWORD | ||
- DATABASE_URL=postgres://mgmnt:mgmntpass@postgres:5432/mgmnt_dev | ||
build: | ||
context: . | ||
dockerfile: ./Dockerfile.dev | ||
volumes: | ||
- ./:/app/ | ||
- node_modules:/app/node_modules | ||
restart: always | ||
networks: | ||
- mgmnt-app | ||
ports: | ||
- 3000:3000 | ||
healthcheck: | ||
test: ['CMD-SHELL', 'curl -s http://localhost:3000/'] | ||
interval: 10s | ||
retries: 5 | ||
start_period: 30s | ||
timeout: 10s | ||
networks: | ||
mgmnt-app: | ||
volumes: | ||
pgdata: | ||
node_modules: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { defineConfig } from 'kysely-ctl' | ||
import { dialect } from './src/database/dialect' | ||
|
||
export default defineConfig({ | ||
dialect, | ||
migrations: { | ||
migrationFolder: 'src/database/migrations', | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
import { createVanillaExtractPlugin } from '@vanilla-extract/next-plugin' | ||
|
||
const withVanillaExtract = createVanillaExtractPlugin() | ||
|
||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = {} | ||
const nextConfig = { | ||
output: 'standalone', | ||
} | ||
|
||
export default withVanillaExtract(nextConfig) |
Oops, something went wrong.