-
-
Notifications
You must be signed in to change notification settings - Fork 20
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 #721 from jetstreamapp/server-refactor
Migrate server to esbuild
- Loading branch information
Showing
26 changed files
with
726 additions
and
260 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 |
---|---|---|
@@ -1,11 +1,48 @@ | ||
.editorconfig | ||
.env | ||
.env.example | ||
.env.staging | ||
.git | ||
.github | ||
.nx | ||
.vscode | ||
.workspace.code-workspace | ||
app | ||
# dist | ||
apps/landing/.next | ||
dist | ||
electron-scripts | ||
logs | ||
node_modules | ||
npm-debug.log | ||
test-results | ||
tmp | ||
yarn-error.log | ||
|
||
# System Files | ||
.DS_Store | ||
Thumbs.db | ||
|
||
# Generated Docusaurus files | ||
.docusaurus/ | ||
.cache-loader/ | ||
|
||
# Next.js | ||
.next | ||
|
||
# Playwright | ||
**/test-results | ||
**/playwright-report | ||
**/playwright/.cache | ||
.nx | ||
|
||
# Not required for core jetstream | ||
apps/cron-tasks | ||
apps/docs | ||
apps/electron | ||
apps/jetstream-e2e | ||
electron-scripts | ||
*# | ||
*~ | ||
.DS_Store | ||
Thumbs.db | ||
|
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
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,41 +1,57 @@ | ||
# docker build -f Dockerfile . -t jetstream | ||
# docker-compose up | ||
# syntax = docker/dockerfile:1 | ||
|
||
# Login and run DB migrations (TODO: figure out how to automate this) | ||
# https://medium.com/@sumankpaul/run-db-migration-script-in-docker-compose-ce8e447a77ba | ||
# docker ps | ||
# docker exec -it 791 bash | ||
# npx prisma migrate deploy | ||
ARG NODE_VERSION=20.10.0 | ||
ARG ENVIRONMENT=production | ||
|
||
# TODO: auth redirect flow is broken, need to fix it | ||
FROM node:${NODE_VERSION}-slim as base | ||
|
||
FROM node:16 | ||
# App lives here | ||
WORKDIR /app | ||
|
||
WORKDIR /usr/src/app | ||
# Set production environment | ||
ENV NODE_ENV=production | ||
ARG YARN_VERSION=1.22.21 | ||
RUN npm install -g yarn@$YARN_VERSION --force | ||
|
||
# Copy application | ||
COPY ./dist/apps/api ./dist/apps/api/ | ||
COPY ./dist/apps/jetstream ./dist/apps/jetstream/ | ||
COPY ./dist/apps/download-zip-sw ./dist/apps/download-zip-sw/ | ||
COPY ./dist/apps/landing ./dist/apps/landing/ | ||
# Throw-away build stage to reduce size of final image | ||
FROM base as build | ||
|
||
# Copy supporting files | ||
COPY ./dist/apps/api/package.json . | ||
COPY ./yarn.lock . | ||
COPY ./.env . | ||
COPY ./ecosystem.config.js . | ||
COPY ./prisma ./prisma/ | ||
# Install packages needed to build node modules | ||
RUN apt-get update -qq && \ | ||
apt-get install --no-install-recommends -y build-essential node-gyp openssl pkg-config python-is-python3 | ||
|
||
# Install core dependencies | ||
RUN yarn | ||
# Install node modules | ||
COPY --link package.json yarn.lock ./ | ||
RUN yarn install --frozen-lockfile --production=false | ||
|
||
# Install other dependencies that were not calculated by nx, but are required | ||
RUN yarn add dotenv prisma@^3.13.0 | ||
# Generate Prisma Client | ||
COPY --link prisma . | ||
RUN yarn run db:generate | ||
|
||
# Generate prisma client - ensure that there are no OS differences | ||
RUN npx prisma generate | ||
# Copy application code | ||
COPY --link . . | ||
|
||
EXPOSE 3333 | ||
EXPOSE 9229 | ||
# Build application | ||
RUN yarn build:core | ||
RUN yarn build:landing | ||
|
||
# Remove development dependencies | ||
RUN yarn install --production=true | ||
|
||
|
||
# Final stage for app image | ||
FROM base | ||
|
||
CMD [ "node", "--inspect=0.0.0.0", "dist/apps/api/main.js" ] | ||
# Install packages needed for deployment | ||
RUN apt-get update -qq && \ | ||
apt-get install --no-install-recommends -y openssl && \ | ||
rm -rf /var/lib/apt/lists /var/cache/apt/archives | ||
|
||
RUN npm install -g [email protected] | ||
|
||
# Copy built application | ||
COPY --from=build /app /app | ||
|
||
# Start the server by default, this can be overwritten at runtime | ||
EXPOSE 3333 | ||
CMD [ "yarn", "run", "start:prod" ] |
This file was deleted.
Oops, something went wrong.
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
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,24 @@ | ||
# This file is generated by Nx. | ||
# | ||
# Build the docker image with `npx nx docker-build api`. | ||
# Tip: Modify "docker-build" options in project.json to change docker build args. | ||
# | ||
# Run the container with `docker run -p 3333:3333 -t api`. | ||
FROM docker.io/node:lts-alpine | ||
|
||
ENV HOST=0.0.0.0 | ||
ENV PORT=3333 | ||
|
||
WORKDIR /app | ||
|
||
RUN addgroup --system api && \ | ||
adduser --system -G api api | ||
|
||
COPY dist/apps/api api | ||
RUN chown -R api:api . | ||
|
||
# You can remove this install step if you build with `--bundle` option. | ||
# The bundled output will include external dependencies. | ||
RUN npm --prefix server --omit=dev -f install | ||
|
||
CMD [ "node", "server" ] |
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,8 +1,11 @@ | ||
/* eslint-disable */ | ||
export default { | ||
coverageDirectory: '../../coverage/apps/api', | ||
globals: {}, | ||
displayName: 'api', | ||
testEnvironment: 'node', | ||
displayName: 'server', | ||
preset: '../../jest.preset.js', | ||
testEnvironment: 'node', | ||
transform: { | ||
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }], | ||
}, | ||
moduleFileExtensions: ['ts', 'js', 'html'], | ||
coverageDirectory: '../../coverage/apps/server', | ||
}; |
Oops, something went wrong.