From ed9b4de1f478f249795c29f80cf9e31dd4ab8480 Mon Sep 17 00:00:00 2001 From: zodiac3k Date: Mon, 14 Oct 2024 16:17:29 +0530 Subject: [PATCH] refactor: Update Dockerfile for improved development and production setup - Migrate from Debian Buster to Debian Bullseye for enhanced stability and security. - Install libvips-dev for optimized image processing. - Configure Node Version Manager (NVM) for Node.js installation from .nvmrc. --- Dockerfile | 47 ++++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index af7b4d901..1e4b6a5d1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,36 +1,47 @@ # STAGE base: Development environment -FROM debian:buster AS base +FROM debian:bullseye AS base ARG DEBIAN_FRONTEND=noninteractive + +# Install system dependencies RUN apt-get update \ - && apt-get upgrade -y \ - && apt-get install -y --no-install-recommends \ - wget \ - ca-certificates \ - && rm -rf /var/lib/apt/lists/* + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends \ + wget \ + ca-certificates \ + build-essential \ + libvips-dev \ + && rm -rf /var/lib/apt/lists/* WORKDIR /devswag -# Install and setup NVM +# Install and setup Node Version Manager SHELL ["/bin/bash", "--login", "-c"] -RUN wget -O- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash +RUN wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash + +# Set the environment variable for NVM +ENV NVM_DIR="/root/.nvm" +RUN ["/bin/bash", "-c", "source $NVM_DIR/nvm.sh && nvm install 14"] + +# Load NVM and install Node.js from .nvmrc COPY .nvmrc ./ -RUN nvm install && nvm use +RUN ["/bin/bash", "-c", "source $NVM_DIR/nvm.sh && nvm install $(cat .nvmrc) && nvm alias default $(cat .nvmrc)"] +# Copy package files and install npm dependencies COPY package.json package-lock.json ./ -RUN set -x \ - # Install npm dependencies - && npm ci \ - # Cleanup - && npm cache clean --force +RUN ["/bin/bash", "-c", "source $NVM_DIR/nvm.sh && npm ci && npm cache clean --force"] + +COPY . . ENV GULP_LISTEN_HOST=0.0.0.0 ENV GULP_LISTEN_PORT=8000 -CMD ["npm", "start"] +EXPOSE 8000 + +CMD ["/bin/bash", "-c", "source $NVM_DIR/nvm.sh && npm start"] ################################ -# Developement image stops here +# Development image stops here # use '--target base' on build to break here # STAGE build: Build environment @@ -49,4 +60,6 @@ FROM nginx:1-alpine AS runtime COPY nginx.conf /etc/nginx/conf.d/default.conf COPY --from=build --chown=nginx:nginx \ - /devswag/dist /usr/share/nginx/html/devswag + /devswag/dist /usr/share/nginx/html/devswag + +EXPOSE 80