Skip to content

Commit 5946752

Browse files
committed
setup for ec2
1 parent 0a5ac0b commit 5946752

File tree

3 files changed

+20
-28
lines changed

3 files changed

+20
-28
lines changed

Dockerfile

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
FROM public.ecr.aws/lambda/nodejs:22
1+
# Use a standard Node.js image instead of the Lambda-specific one
2+
FROM node:22-alpine
23

3-
# Copy and build TypeScript
4-
WORKDIR /var/task
4+
WORKDIR /usr/src/app
55

66
COPY package*.json ./
7-
RUN npm install
7+
# Install production dependencies
8+
RUN npm install --omit=dev
89

910
COPY . .
11+
# Build your TypeScript code
1012
RUN npm run build
1113

12-
CMD [ "dist/server.handler" ]
14+
# Expose the port your app will run on
15+
EXPOSE 3000
16+
17+
# Change the command to start the server directly
18+
CMD [ "node", "dist/server.js" ]

prisma/schema.prisma

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
generator client {
22
provider = "prisma-client-js"
3-
binaryTargets = ["native", "rhel-openssl-1.0.x", "rhel-openssl-3.0.x"]
3+
binaryTargets = ["native", "rhel-openssl-1.0.x", "rhel-openssl-3.0.x", "linux-musl-openssl-3.0.x"]
44
}
55

66
datasource db {

src/server.ts

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import 'dotenv/config';
22
import express from 'express';
33
import cors from 'cors';
4-
import serverlessExpress from '@vendia/serverless-express';
5-
import busboy from 'busboy';
64
import profileRoutes from './routes/profileRoutes'
75
import eventRoutes from './routes/eventRoutes'
86
import guestRoutes from './routes/guestRoutes'
@@ -79,32 +77,20 @@ app.use((error: any, req: express.Request, res: express.Response, next: express.
7977
res.status(500).json({ error: 'Internal server error', message: error.message });
8078
});
8179

82-
// Create the serverless handler with configuration
83-
export const handler = serverlessExpress({
84-
app,
85-
binaryMimeTypes: [
86-
'application/octet-stream',
87-
'font/*',
88-
'image/*',
89-
'video/*',
90-
'audio/*'
91-
]
92-
});
93-
9480
async function startServer() {
9581
try {
9682
await prisma.$connect();
9783
console.log('Connected to DB');
84+
85+
const port = process.env.PORT || 3000;
86+
app.listen(port, () => {
87+
console.log(`✅ Server running at http://localhost:${port}`);
88+
});
9889
} catch (err) {
99-
console.error('Failed to connect to DB:', err);
90+
console.error('Failed to connect to DB:', err);
10091
process.exit(1);
10192
}
102-
const port = process.env.PORT || 3000;
103-
app.listen(port, () => {
104-
console.log(`Server running at http://localhost:${port}`);
105-
});
10693
}
10794

108-
if (process.env.NODE_ENV !== 'production' && !process.env.AWS_LAMBDA_FUNCTION_NAME) {
109-
startServer();
110-
}
95+
// Start the server
96+
startServer();

0 commit comments

Comments
 (0)