chat-with-gpt/Dockerfile

56 lines
1.1 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
# Copy public, and src directories
2023-03-14 11:00:40 +00:00
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-29 18:27:10 +00:00
FROM node:19-bullseye-slim 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
2023-04-29 18:27:10 +00:00
# RUN apt-get update && \
# apt-get install -y \
# curl \
# build-essential \
# libssl-dev \
# openssl
2023-04-15 10:33:19 +00:00
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"]