-
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.
feat(apps/earth): starts adding in deployment
- Loading branch information
1 parent
b9adc79
commit aa8a78e
Showing
16 changed files
with
1,481 additions
and
272 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 @@ | ||
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
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 |
---|---|---|
|
@@ -37,3 +37,4 @@ lib-types | |
|
||
# turbo | ||
.turbo | ||
out |
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 +1 @@ | ||
server/ | ||
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# * Pruner * # | ||
FROM node:18 AS pruner | ||
|
||
WORKDIR /app | ||
|
||
COPY ./ ./ | ||
|
||
# Prune | ||
RUN npx -y turbo prune --scope="@deopea.os/earth" --docker | ||
# * Pruner * # | ||
|
||
# * Builder * # | ||
FROM node:18 AS builder | ||
|
||
WORKDIR /app | ||
|
||
# Install | ||
COPY .gitignore ./ | ||
COPY --from=pruner \ | ||
# sources | ||
/app/out/json/ \ | ||
/app/out/package-lock.json \ | ||
# destination | ||
./ | ||
|
||
# Install | ||
RUN npm ci --omit="dev" | ||
|
||
# Build | ||
COPY --from=pruner /app/out/full/ ./ | ||
RUN npx turbo build --filter="@deopea.os/earth" | ||
# * Builder * # | ||
|
||
# * Runner * # | ||
FROM node:18 AS runner | ||
|
||
WORKDIR /app | ||
|
||
# User | ||
RUN addgroup --system --gid 1001 app | ||
RUN adduser --system --uid 1001 app | ||
USER app | ||
|
||
COPY --from=builder /app/apps/earth/package.json . | ||
COPY --from=builder --chown=app:app /app/apps/earth/dist dist | ||
COPY --from=builder --chown=app:app /app/apps/earth/server server | ||
|
||
CMD npm start |
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,15 @@ | ||
import { expressAdapter } from '@builder.io/qwik-city/adapters/express/vite'; | ||
import { extendConfig } from '@builder.io/qwik-city/vite'; | ||
import baseConfig from '../../vite.config'; | ||
|
||
export default extendConfig(baseConfig, () => { | ||
return { | ||
build: { | ||
ssr: true, | ||
rollupOptions: { | ||
input: ['src/entry.express.tsx', '@qwik-city-plan'], | ||
}, | ||
}, | ||
plugins: [expressAdapter()], | ||
}; | ||
}); |
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,50 @@ | ||
/* | ||
* WHAT IS THIS FILE? | ||
* | ||
* It's the entry point for the express server when building for production. | ||
* | ||
* Learn more about the cloudflare integration here: | ||
* - https://qwik.builder.io/integrations/deployments/node/ | ||
* | ||
*/ | ||
import { createQwikCity } from '@builder.io/qwik-city/middleware/node'; | ||
import qwikCityPlan from '@qwik-city-plan'; | ||
import render from './entry.ssr'; | ||
import express from 'express'; | ||
import { fileURLToPath } from 'node:url'; | ||
import { join } from 'node:path'; | ||
// import compression from 'compression'; | ||
|
||
// Directories where the static assets are located | ||
const distDir = join(fileURLToPath(import.meta.url), '..', '..', 'dist'); | ||
const buildDir = join(distDir, 'build'); | ||
|
||
// Allow for dynamic port | ||
const PORT = process.env.PORT ?? 3000; | ||
|
||
// Create the Qwik City express middleware | ||
const { router, notFound } = createQwikCity({ render, qwikCityPlan }); | ||
|
||
// Create the express server | ||
// https://expressjs.com/ | ||
const app = express(); | ||
|
||
// Enable gzip compression | ||
// app.use(compression()); | ||
|
||
// Static asset handlers | ||
// https://expressjs.com/en/starter/static-files.html | ||
app.use(`/build`, express.static(buildDir, { immutable: true, maxAge: '1y' })); | ||
app.use(express.static(distDir, { redirect: false })); | ||
|
||
// Use Qwik City's page and endpoint request handler | ||
app.use(router); | ||
|
||
// Use Qwik City's 404 handler | ||
app.use(notFound); | ||
|
||
// Start the express server | ||
app.listen(PORT, () => { | ||
/* eslint-disable */ | ||
console.log(`Server starter: http://localhost:${PORT}/`); | ||
}); |
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 @@ | ||
import * as apigateway from "aws-cdk-lib/aws-apigateway"; | ||
import * as lambda from "aws-cdk-lib/aws-lambda"; | ||
import { Construct } from "constructs"; | ||
|
||
export class APIStack extends Construct { | ||
constructor(scope: Construct, id: string) { | ||
super(scope, id); | ||
|
||
const api = new apigateway.RestApi(this, "earth-api", { | ||
restApiName: "Earth API", | ||
description: "API for Deopea/Earth", | ||
}); | ||
|
||
const ssrHandler = new lambda.DockerImageFunction(this, "ClientHandler", { | ||
code: lambda.DockerImageCode.fromImageAsset(__dirname), | ||
}); | ||
|
||
const ssrRoot = api.root.addResource("/ssr"); | ||
ssrRoot.addMethod( | ||
"GET", | ||
new apigateway.LambdaIntegration(ssrHandler, { proxy: true }), | ||
); | ||
} | ||
} |
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,8 @@ | ||
#!/usr/bin/env node | ||
|
||
import * as cdk from "aws-cdk-lib"; | ||
import { APIStack } from "./api"; | ||
|
||
const app = new cdk.App(); | ||
|
||
new APIStack(app, "APIStack"); |
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,10 @@ | ||
version: "3" | ||
|
||
services: | ||
earth: | ||
container_name: earth | ||
build: | ||
context: . | ||
dockerfile: apps/earth/Dockerfile | ||
ports: | ||
- 8080:4173 |
Oops, something went wrong.