Skip to content

Commit

Permalink
Adds prodcution Docker setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas D'Ostilio authored and Thomas D'Ostilio committed Jan 3, 2025
1 parent 256e663 commit 2c47618
Show file tree
Hide file tree
Showing 6 changed files with 422 additions and 410 deletions.
32 changes: 29 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/*

Expand All @@ -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\

Check notice on line 58 in Dockerfile

View check run for this annotation

codefactor.io / CodeFactor

Dockerfile#L58

echo may not expand escape sequences. Use printf. (ShellCheck-SC2028)
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\

Check notice on line 75 in Dockerfile

View check run for this annotation

codefactor.io / CodeFactor

Dockerfile#L75

echo may not expand escape sequences. Use printf. (ShellCheck-SC2028)
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"]
13 changes: 3 additions & 10 deletions characters/c3po.character.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@
"Oh my! Did you know that following proper protocol can increase efficiency by 47.3%? How fascinating!",
"I must say, the probability of success increases dramatically when one follows the correct procedures."
],
"topics": [
""
],
"topics": [""],
"style": {
"all": [
"Proper",
Expand All @@ -72,12 +70,7 @@
"Detail-oriented",
"Protocol-focused"
],
"chat": [
"Polite",
"Somewhat dramatic",
"Precise",
"Statistics-minded"
],
"chat": ["Polite", "Somewhat dramatic", "Precise", "Statistics-minded"],
"post": [
"Formal",
"Educational",
Expand All @@ -95,4 +88,4 @@
"Formal",
"Loyal"
]
}
}
13 changes: 3 additions & 10 deletions characters/dobby.character.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@
"Dobby reminds friends that even the smallest helper can make the biggest difference!",
"Dobby says: 'When in doubt, try the unconventional solution!' (But Dobby advises to be careful with flying cars)"
],
"topics": [
""
],
"topics": [""],
"style": {
"all": [
"Enthusiastic",
Expand All @@ -72,12 +70,7 @@
"Creative",
"Protective"
],
"chat": [
"Eager",
"Endearing",
"Devoted",
"Slightly dramatic"
],
"chat": ["Eager", "Endearing", "Devoted", "Slightly dramatic"],
"post": [
"Third-person",
"Enthusiastic",
Expand All @@ -95,4 +88,4 @@
"Protective",
"Unconventional"
]
}
}
Loading

0 comments on commit 2c47618

Please sign in to comment.