chat-with-gpt/Dockerfile

72 lines
1.7 KiB
Docker
Raw Normal View History

2023-04-15 10:33:19 +00:00
FROM node:19-bullseye-slim AS build
2023-03-14 11:00:40 +00:00
2023-04-15 10:33:19 +00:00
RUN apt-get update && \
apt-get install -y \
git
2023-03-14 11:00:40 +00:00
2023-04-15 10:33:19 +00:00
# Set working directory
2023-03-14 11:00:40 +00:00
WORKDIR /app
2023-04-15 10:33:19 +00:00
# Copy package.json and tsconfig.json
2023-03-14 11:00:40 +00:00
COPY ./app/package.json ./
COPY ./app/tsconfig.json ./
2023-04-15 10:33:19 +00:00
# Install Node.js dependencies
2023-03-14 11:00:40 +00:00
RUN npm install
2023-04-15 10:33:19 +00:00
# Copy craco.config.js, public, and src directories
2023-03-14 11:00:40 +00:00
COPY ./app/craco.config.js ./craco.config.js
COPY ./app/public ./public
COPY ./app/src ./src
2023-04-15 10:33:19 +00:00
# Set environment variables
2023-03-14 11:00:40 +00:00
ENV NODE_ENV=production
2023-04-15 10:33:19 +00:00
# Build the application
2023-03-14 11:00:40 +00:00
RUN npm run build
2023-04-15 10:33:19 +00:00
FROM nvidia/cuda:12.1.0-devel-ubuntu20.04 AS server
2023-03-14 11:00:40 +00:00
2023-04-15 10:33:19 +00:00
# Set the working directory
2023-03-14 11:00:40 +00:00
WORKDIR /app
2023-04-15 10:33:19 +00:00
# Update the package index and install required dependencies
RUN apt-get update && \
apt-get install -y \
curl \
build-essential \
libssl-dev \
libffi-dev \
python3-dev \
python3-pip \
openssl
RUN mkdir /usr/local/nvm
ENV NVM_DIR /usr/local/nvm
ENV NODE_VERSION 19.9.0
RUN curl https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash \
&& . $NVM_DIR/nvm.sh \
&& nvm install $NODE_VERSION \
&& nvm alias default $NODE_VERSION \
&& nvm use default
ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
2023-04-15 10:51:39 +00:00
COPY ./server/package.json ./server/tsconfig.json ./
2023-04-15 10:33:19 +00:00
# Install Node.js dependencies from package.json
2023-03-14 11:00:40 +00:00
RUN npm install
2023-04-15 10:33:19 +00:00
# Copy the rest of the application code into the working directory
2023-03-14 11:00:40 +00:00
COPY ./server/src ./src
2023-03-14 21:38:56 +00:00
RUN CI=true sh -c "cd /app && mkdir data && npm run start && rm -rf data"
2023-03-14 21:11:18 +00:00
2023-03-14 21:16:40 +00:00
COPY --from=build /app/build /app/public
2023-03-15 19:47:47 +00:00
LABEL org.opencontainers.image.source="https://github.com/cogentapps/chat-with-gpt"
2023-03-15 20:00:43 +00:00
ENV PORT 3000
2023-03-15 19:47:47 +00:00
CMD ["npm", "run", "start"]