Commit
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# Start the backend server in the background
|
# Start the backend server in the background
|
||||||
node /backend/server.js &
|
node /backend/server.js &
|
||||||
|
|
||||||
# Start Nginx in the foreground
|
# Start Nginx in the foreground
|
||||||
nginx -g "daemon off;"
|
nginx -g "daemon off;"
|
||||||
@@ -1,14 +1,11 @@
|
|||||||
# Build frontend
|
# Build frontend
|
||||||
FROM ubuntu:20.04 AS frontend-build
|
FROM ubuntu:20.04 AS frontend-build
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
# Install Node.js and npm
|
# Install Node.js
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y curl && \
|
||||||
curl \
|
curl -sL https://deb.nodesource.com/setup_18.x | bash - && \
|
||||||
gnupg2 \
|
apt-get install -y nodejs && \
|
||||||
lsb-release \
|
rm -rf /var/lib/apt/lists/*
|
||||||
&& curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
|
|
||||||
&& apt-get install -y nodejs \
|
|
||||||
&& apt-get clean
|
|
||||||
COPY frontend/package*.json ./frontend/
|
COPY frontend/package*.json ./frontend/
|
||||||
RUN npm --prefix frontend install
|
RUN npm --prefix frontend install
|
||||||
COPY frontend/ ./frontend/
|
COPY frontend/ ./frontend/
|
||||||
@@ -17,39 +14,27 @@ RUN npm --prefix frontend run build
|
|||||||
# Build backend
|
# Build backend
|
||||||
FROM ubuntu:20.04 AS backend-build
|
FROM ubuntu:20.04 AS backend-build
|
||||||
WORKDIR /backend
|
WORKDIR /backend
|
||||||
# Install Node.js and npm
|
# Install Node.js
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y curl && \
|
||||||
curl \
|
curl -sL https://deb.nodesource.com/setup_18.x | bash - && \
|
||||||
gnupg2 \
|
apt-get install -y nodejs && \
|
||||||
lsb-release \
|
rm -rf /var/lib/apt/lists/*
|
||||||
&& curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
|
|
||||||
&& apt-get install -y nodejs \
|
|
||||||
&& apt-get clean
|
|
||||||
COPY backend/package*.json ./
|
COPY backend/package*.json ./
|
||||||
RUN npm install
|
RUN npm install
|
||||||
COPY backend/ .
|
COPY backend/ .
|
||||||
|
|
||||||
# Production image
|
# Production image
|
||||||
FROM ubuntu:20.04
|
FROM ubuntu:20.04
|
||||||
# Install Node.js and nginx
|
# Install Node.js and Nginx
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y curl nginx && \
|
||||||
curl \
|
curl -sL https://deb.nodesource.com/setup_18.x | bash - && \
|
||||||
nginx \
|
apt-get install -y nodejs && \
|
||||||
gnupg2 \
|
rm -rf /var/lib/apt/lists/*
|
||||||
lsb-release \
|
# Copy frontend and backend
|
||||||
&& curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
|
|
||||||
&& apt-get install -y nodejs \
|
|
||||||
&& apt-get clean
|
|
||||||
|
|
||||||
# Copy frontend static files to nginx folder
|
|
||||||
COPY --from=frontend-build /app/frontend/dist /usr/share/nginx/html
|
COPY --from=frontend-build /app/frontend/dist /usr/share/nginx/html
|
||||||
# Copy backend application
|
|
||||||
COPY --from=backend-build /backend /backend
|
COPY --from=backend-build /backend /backend
|
||||||
# Copy entrypoint script
|
# Copy entrypoint script
|
||||||
COPY --from=backend-build /backend/entrypoint.sh /backend/entrypoint.sh
|
COPY backend/entrypoint.sh /backend/entrypoint.sh
|
||||||
|
|
||||||
# Make entrypoint.sh executable
|
|
||||||
RUN chmod +x /backend/entrypoint.sh
|
RUN chmod +x /backend/entrypoint.sh
|
||||||
|
# Start backend and frontend servers using entrypoint script
|
||||||
# Use entrypoint script to start backend and frontend servers
|
CMD ["/backend/entrypoint.sh"]
|
||||||
ENTRYPOINT ["/backend/entrypoint.sh"]
|
|
||||||
Reference in New Issue
Block a user