-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Thomas D'Ostilio
authored and
Thomas D'Ostilio
committed
Jan 3, 2025
1 parent
256e663
commit 2c47618
Showing
6 changed files
with
422 additions
and
410 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 |
---|---|---|
|
@@ -22,19 +22,21 @@ COPY agent ./agent | |
COPY packages ./packages | ||
COPY scripts ./scripts | ||
COPY characters ./characters | ||
COPY client ./client | ||
|
||
# Install dependencies and build the project | ||
RUN pnpm install \ | ||
&& pnpm build-docker \ | ||
&& pnpm --dir client build \ | ||
&& pnpm prune --prod | ||
|
||
# Create a new stage for the final image | ||
FROM node:23.3.0-slim | ||
|
||
# Install runtime dependencies if needed | ||
# Install runtime dependencies and nginx | ||
RUN npm install -g [email protected] && \ | ||
apt-get update && \ | ||
apt-get install -y git python3 && \ | ||
apt-get install -y git python3 nginx && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
|
@@ -50,6 +52,30 @@ COPY --from=builder /app/agent ./agent | |
COPY --from=builder /app/packages ./packages | ||
COPY --from=builder /app/scripts ./scripts | ||
COPY --from=builder /app/characters ./characters | ||
COPY --from=builder /app/client/dist ./client/dist | ||
|
||
# Configure nginx | ||
RUN echo 'server {\n\ | ||
listen 3001;\n\ | ||
server_name localhost;\n\ | ||
root /app/client/dist;\n\ | ||
location / {\n\ | ||
try_files $uri $uri/ /index.html;\n\ | ||
}\n\ | ||
location /api/ {\n\ | ||
proxy_pass http://localhost:3000/;\n\ | ||
proxy_http_version 1.1;\n\ | ||
proxy_set_header Upgrade $http_upgrade;\n\ | ||
proxy_set_header Connection "upgrade";\n\ | ||
proxy_set_header Host $host;\n\ | ||
}\n\ | ||
}' > /etc/nginx/conf.d/default.conf | ||
|
||
# Create a start script that runs both server and nginx | ||
RUN echo '#!/bin/bash\n\ | ||
pnpm start --character="characters/trump.character.json" & \ | ||
nginx -g "daemon off;" & \ | ||
wait' > /app/start.sh && chmod +x /app/start.sh | ||
|
||
# Set the command to run the application | ||
CMD ["pnpm", "start"] | ||
CMD ["/app/start.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
Oops, something went wrong.