45 lines
1.1 KiB
Docker
45 lines
1.1 KiB
Docker
# Use the official Ubuntu base image
|
|
FROM ubuntu:22.04
|
|
|
|
# Set environment variables to avoid prompts during package installations
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
# Update the package list and install necessary dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
curl \
|
|
gnupg2 \
|
|
build-essential \
|
|
unzip
|
|
|
|
RUN curl -fsSL https://fnm.vercel.app/install | bash \
|
|
&& export PATH="/root/.fnm:$PATH" \
|
|
&& eval "$(fnm env)" \
|
|
&& fnm install 22 \
|
|
&& fnm use 22 \
|
|
&& fnm alias default 22
|
|
|
|
# Install nodemon globally
|
|
RUN export PATH="/root/.fnm:$PATH" \
|
|
&& eval "$(fnm env)" \
|
|
&& npm install -g nodemon
|
|
|
|
# Set the working directory inside the container
|
|
WORKDIR /home/node/app
|
|
|
|
# Copy the package.json and package-lock.json files to the container
|
|
COPY package*.json ./
|
|
|
|
# Install the application dependencies
|
|
RUN export PATH="/root/.fnm:$PATH" \
|
|
&& eval "$(fnm env)" \
|
|
&& npm install --legacy-peer-deps
|
|
|
|
# Copy the rest of the application code to the container
|
|
COPY . .
|
|
|
|
# Expose the application port
|
|
EXPOSE 3000
|
|
|
|
# Default command (can be overridden by docker-compose)
|
|
CMD ["npm", "start"]
|