Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compose docker build #2

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,8 @@ dist
# should be here otherwise if placed inside prisma-client pnpm deploy doesn't copy it
packages/prisma-client/src/__generated__

.temp
.temp


.nx/cache
.nx/workspace-data
31 changes: 31 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM node:22.13.1-alpine AS builder

# Set working directory
WORKDIR /app

# Copy application files
COPY packages/ ./packages
COPY pnpm-workspace.yaml ./
COPY apps/builder/ ./

# Install dependencies
RUN corepack enable && corepack prepare pnpm@latest --activate
RUN pnpm install

# Build the application (if needed, adjust accordingly)
RUN pnpm run build

# -- Second Stage: Production Image --
FROM node:22.13.1-alpine AS production

# Set working directory
WORKDIR /app

# Copy only necessary files from builder stage
COPY --from=builder /app .

# Expose necessary port
EXPOSE 13100

# Set entry point
CMD ["npx", "remix-serve", "build/server/index.js"]
5 changes: 1 addition & 4 deletions apps/builder/.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
DATABASE_URL=postgresql://postgres:pass@localhost/webstudio?pgbouncer=true
DIRECT_URL=postgresql://postgres:pass@localhost/webstudio

AUTH_SECRET="# Linux: $(openssl rand -hex 32) or go to https://generate-secret.now.sh/64"
AUTH_SECRET="rand"
DEV_LOGIN=true

# Restrictions
Expand Down Expand Up @@ -47,13 +47,10 @@ FEATURES=*
# Current user plan features (default)
USER_PLAN=pro


# TRCP server url and API token. If empty local TRPC server is used
# TRPC_SERVER_URL=
# TRPC_SERVER_API_TOKEN=

# AI Features
# OPENAI_KEY=
# OPENAI_ORG=


90 changes: 45 additions & 45 deletions apps/builder/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default defineConfig(({ mode }) => {
return {
plugins: [
remix({
presets: [vercelPreset()],
presets: [],
future: {
v3_lazyRouteDiscovery: false,
v3_relativeSplatPath: false,
Expand Down Expand Up @@ -86,50 +86,50 @@ export default defineConfig(({ mode }) => {
define: {
"process.env.NODE_ENV": JSON.stringify(mode),
},
server: {
// Service-to-service OAuth token call requires a specified host for the wstd.dev domain
host: "wstd.dev",
// Needed for SSL
proxy: {},

https: {
key: readFileSync("../../https/privkey.pem"),
cert: readFileSync("../../https/fullchain.pem"),
},
cors: ((
req: IncomingMessage,
callback: (error: Error | null, options: CorsOptions | null) => void
) => {
// Handle CORS preflight requests in development to mimic Remix production behavior
if (req.method === "OPTIONS" || req.method === "POST") {
if (req.headers.origin != null && req.url != null) {
const url = new URL(req.url, `https://${req.headers.host}`);

// Allow CORS for /builder-logout path when requested from the authorization server
if (url.pathname === "/builder-logout" && isBuilderUrl(url.href)) {
return callback(null, {
origin: getAuthorizationServerOrigin(url.href),
preflightContinue: false,
credentials: true,
});
}
}

if (req.method === "OPTIONS") {
// Respond with method not allowed for other preflight requests
return callback(null, {
preflightContinue: false,
optionsSuccessStatus: 405,
});
}
}

// Disable CORS for all other requests
return callback(null, {
origin: false,
});
}) as never,
},
// server: {
// // Service-to-service OAuth token call requires a specified host for the wstd.dev domain
// host: "wstd.dev",
// // Needed for SSL
// proxy: {},
//
// https: {
// key: readFileSync("../../https/privkey.pem"),
// cert: readFileSync("../../https/fullchain.pem"),
// },
// cors: ((
// req: IncomingMessage,
// callback: (error: Error | null, options: CorsOptions | null) => void
// ) => {
// // Handle CORS preflight requests in development to mimic Remix production behavior
// if (req.method === "OPTIONS" || req.method === "POST") {
// if (req.headers.origin != null && req.url != null) {
// const url = new URL(req.url, `https://${req.headers.host}`);
//
// // Allow CORS for /builder-logout path when requested from the authorization server
// if (url.pathname === "/builder-logout" && isBuilderUrl(url.href)) {
// return callback(null, {
// origin: getAuthorizationServerOrigin(url.href),
// preflightContinue: false,
// credentials: true,
// });
// }
// }
//
// if (req.method === "OPTIONS") {
// // Respond with method not allowed for other preflight requests
// return callback(null, {
// preflightContinue: false,
// optionsSuccessStatus: 405,
// });
// }
// }
//
// // Disable CORS for all other requests
// return callback(null, {
// origin: false,
// });
// }) as never,
// },
envPrefix: "GITHUB_",
};
});