From 3ee91ed963bfca21d2e1c072dc434dab7161e945 Mon Sep 17 00:00:00 2001 From: Luke Gustafson Date: Wed, 27 Nov 2024 03:48:26 +0000 Subject: [PATCH] Commit --- backend/entrypoint.sh | 2 -- docker/Dockerfile | 53 ++++++++++++++++--------------------------- 2 files changed, 19 insertions(+), 36 deletions(-) diff --git a/backend/entrypoint.sh b/backend/entrypoint.sh index a4818852..4ff0b11c 100644 --- a/backend/entrypoint.sh +++ b/backend/entrypoint.sh @@ -1,7 +1,5 @@ #!/bin/sh - # Start the backend server in the background node /backend/server.js & - # Start Nginx in the foreground nginx -g "daemon off;" \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index 56605af4..1fcf5bc9 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,14 +1,11 @@ # Build frontend FROM ubuntu:20.04 AS frontend-build WORKDIR /app -# Install Node.js and npm -RUN apt-get update && apt-get install -y \ - curl \ - gnupg2 \ - lsb-release \ - && curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \ - && apt-get install -y nodejs \ - && apt-get clean +# Install Node.js +RUN apt-get update && apt-get install -y curl && \ + curl -sL https://deb.nodesource.com/setup_18.x | bash - && \ + apt-get install -y nodejs && \ + rm -rf /var/lib/apt/lists/* COPY frontend/package*.json ./frontend/ RUN npm --prefix frontend install COPY frontend/ ./frontend/ @@ -17,39 +14,27 @@ RUN npm --prefix frontend run build # Build backend FROM ubuntu:20.04 AS backend-build WORKDIR /backend -# Install Node.js and npm -RUN apt-get update && apt-get install -y \ - curl \ - gnupg2 \ - lsb-release \ - && curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \ - && apt-get install -y nodejs \ - && apt-get clean +# Install Node.js +RUN apt-get update && apt-get install -y curl && \ + curl -sL https://deb.nodesource.com/setup_18.x | bash - && \ + apt-get install -y nodejs && \ + rm -rf /var/lib/apt/lists/* COPY backend/package*.json ./ RUN npm install COPY backend/ . # Production image FROM ubuntu:20.04 -# Install Node.js and nginx -RUN apt-get update && apt-get install -y \ - curl \ - nginx \ - gnupg2 \ - lsb-release \ - && 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 +# Install Node.js and Nginx +RUN apt-get update && apt-get install -y curl nginx && \ + curl -sL https://deb.nodesource.com/setup_18.x | bash - && \ + apt-get install -y nodejs && \ + rm -rf /var/lib/apt/lists/* +# Copy frontend and backend COPY --from=frontend-build /app/frontend/dist /usr/share/nginx/html -# Copy backend application COPY --from=backend-build /backend /backend # Copy entrypoint script -COPY --from=backend-build /backend/entrypoint.sh /backend/entrypoint.sh - -# Make entrypoint.sh executable +COPY backend/entrypoint.sh /backend/entrypoint.sh RUN chmod +x /backend/entrypoint.sh - -# Use entrypoint script to start backend and frontend servers -ENTRYPOINT ["/backend/entrypoint.sh"] \ No newline at end of file +# Start backend and frontend servers using entrypoint script +CMD ["/backend/entrypoint.sh"] \ No newline at end of file