Skip to content

Commit e19145a

Browse files
committed
Add multi-stage Dockerfile for client and server; remove old Dockerfiles
1 parent 35d34fd commit e19145a

File tree

4 files changed

+59
-55
lines changed

4 files changed

+59
-55
lines changed

Dockerfile

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Use the official Node.js image as the base image
2+
FROM node:latest AS build_client
3+
4+
# Set the working directory inside the container
5+
WORKDIR /app
6+
7+
# Copy the .git directory to the container to allow for the use of the git hash in the Vite project
8+
COPY .git /app/.git
9+
10+
# Copy the package.json and package-lock.json files to the container
11+
COPY client/ /app
12+
13+
ARG VITE_API_URL
14+
ARG VITE_MAX_VM_COUNT
15+
16+
ENV VITE_API_URL=$VITE_API_URL
17+
ENV VITE_MAX_VM_COUNT=$VITE_MAX_VM_COUNT
18+
19+
# Install the project dependencies
20+
RUN npm install
21+
22+
# Build the Vite project
23+
RUN npm run build
24+
25+
# Use the official Nginx image as the base image for serving the built files
26+
FROM nginx:latest AS serve_client
27+
28+
# Copy the built files from the previous stage to the Nginx container
29+
COPY --from=build_client /app/dist /usr/share/nginx/html
30+
31+
# Copy the Nginx configuration file to the container
32+
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
33+
34+
# Expose the port Nginx will listen on
35+
ARG PORT
36+
37+
EXPOSE $PORT
38+
39+
# Start the Nginx server
40+
CMD ["nginx", "-g", "daemon off;"]
41+
42+
FROM python:3.12 AS build_server
43+
44+
# Set the working directory
45+
WORKDIR /app
46+
47+
# Copy the current directory contents into the container at /server
48+
COPY server/ /app
49+
50+
# Install qemu-system-x86_64
51+
RUN apt-get update && apt-get install -y qemu-system
52+
53+
# Install any needed packages specified in requirements.txt
54+
RUN pip install --no-cache-dir -r requirements.txt
55+
56+
# Run gunicorn
57+
CMD ["gunicorn", "app:app"]

client/.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
2-
dist
2+
dist
3+
.env

client/Dockerfile

Lines changed: 0 additions & 32 deletions
This file was deleted.

server/Dockerfile

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)