-
-
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.
- Added support for a single container to run the backend and frontend from. - Still allows for separate frontend and backend hostnames to allow for API Gateways.
- Loading branch information
1 parent
284a483
commit 1a5765d
Showing
4 changed files
with
80 additions
and
13 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,60 @@ | ||
# Use the official Node.js 22 image as the base | ||
FROM node:22 | ||
|
||
# Set a root working directory | ||
WORKDIR /usr/src/app | ||
|
||
# Copy the .env file into the container for both frontend and backend | ||
COPY .env .env | ||
|
||
# -------- Backend Setup -------- | ||
|
||
# Set the working directory for the backend | ||
WORKDIR /usr/src/app/keyfade-backend | ||
|
||
# Copy backend package.json and package-lock.json | ||
COPY keyfade-backend/package*.json ./ | ||
|
||
# Install backend dependencies | ||
RUN npm install | ||
|
||
# Copy the rest of the backend code | ||
COPY keyfade-backend . | ||
|
||
# -------- Frontend Setup -------- | ||
|
||
# Set the working directory for the frontend | ||
WORKDIR /usr/src/app/keyfade-frontend | ||
|
||
# Copy frontend package.json and package-lock.json | ||
COPY keyfade-frontend/package*.json ./ | ||
|
||
# Install frontend dependencies | ||
RUN npm install | ||
|
||
# Copy the rest of the frontend code | ||
COPY keyfade-frontend . | ||
|
||
# Copy the .env file into the frontend directory (if required by build tools) | ||
RUN cp /usr/src/app/.env /usr/src/app/keyfade-frontend/.env | ||
|
||
# Build the frontend app | ||
RUN npm run build | ||
|
||
# Clean up unnecessary files | ||
RUN rm -f /usr/src/app/keyfade-frontend/.env | ||
|
||
# -------- Final Steps -------- | ||
|
||
# Set the working directory back to the root | ||
WORKDIR /usr/src/app | ||
|
||
# Expose both frontend and backend ports | ||
EXPOSE 3001 3002 | ||
|
||
# Copy the start script | ||
COPY start.sh /usr/src/app/start.sh | ||
RUN chmod +x /usr/src/app/start.sh | ||
|
||
# Start the applications using the start script | ||
CMD ["/usr/src/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
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,13 @@ | ||
#!/bin/bash | ||
|
||
# Start the backend process | ||
node /usr/src/app/keyfade-backend/index.js & | ||
|
||
# Start the frontend process | ||
npx serve -s /usr/src/app/keyfade-frontend/dist -l 3001 & | ||
|
||
# Wait for any process to exit | ||
wait -n | ||
|
||
# Exit with the status of the process that exited first | ||
exit $? |