From 8d08260ae885cc3bc152b9f5797645a926ca74a1 Mon Sep 17 00:00:00 2001 From: nsxshota Date: Mon, 20 Nov 2023 17:56:57 +0900 Subject: [PATCH] modified: Dockerfile for cdk --- Dockerfile | 22 +++++++++++++--------- dev.Dockerfile | 18 ------------------ prod.Dockerfile | 15 +++++++++++++++ src/frontend/Dockerfile | 36 +++++++++++++++++++++++------------- src/frontend/dev.Dockerfile | 26 -------------------------- src/frontend/prod.Dockerfile | 16 ++++++++++++++++ 6 files changed, 67 insertions(+), 66 deletions(-) delete mode 100644 dev.Dockerfile create mode 100644 prod.Dockerfile delete mode 100644 src/frontend/dev.Dockerfile create mode 100644 src/frontend/prod.Dockerfile diff --git a/Dockerfile b/Dockerfile index 346348c0a..762c27f90 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,19 @@ -FROM python:3.10-slim +FROM --platform=linux/amd64 python:3.10-slim -RUN apt-get update && apt-get install gcc g++ git make -y && apt-get clean \ - && rm -rf /var/lib/apt/lists/* -RUN useradd -m -u 1000 user -USER user -ENV HOME=/home/user \ - PATH=/home/user/.local/bin:$PATH +WORKDIR /app -WORKDIR $HOME/app +# Install Poetry +RUN apt-get update && apt-get install gcc g++ curl build-essential postgresql-server-dev-all -y +RUN curl -sSL https://install.python-poetry.org | python3 - +# # Add Poetry to PATH +ENV PATH="${PATH}:/root/.local/bin" +# # Copy the pyproject.toml and poetry.lock files +COPY poetry.lock pyproject.toml ./ +# Copy the rest of the application codes +COPY ./ ./ -COPY --chown=user . $HOME/app +# Install dependencies +RUN poetry config virtualenvs.create false && poetry install --no-interaction --no-ansi RUN pip install langflow>==0.5.0 -U --user CMD ["python", "-m", "langflow", "run", "--host", "0.0.0.0", "--port", "7860"] diff --git a/dev.Dockerfile b/dev.Dockerfile deleted file mode 100644 index ed3631516..000000000 --- a/dev.Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM python:3.10-slim - -WORKDIR /app - -# Install Poetry -RUN apt-get update && apt-get install gcc g++ curl build-essential postgresql-server-dev-all -y -RUN curl -sSL https://install.python-poetry.org | python3 - -# # Add Poetry to PATH -ENV PATH="${PATH}:/root/.local/bin" -# # Copy the pyproject.toml and poetry.lock files -COPY poetry.lock pyproject.toml ./ -# Copy the rest of the application codes -COPY ./ ./ - -# Install dependencies -RUN poetry config virtualenvs.create false && poetry install --no-interaction --no-ansi - -CMD ["uvicorn", "--factory", "src.backend.langflow.main:create_app", "--host", "0.0.0.0", "--port", "7860", "--reload", "--log-level", "debug"] diff --git a/prod.Dockerfile b/prod.Dockerfile new file mode 100644 index 000000000..520c407de --- /dev/null +++ b/prod.Dockerfile @@ -0,0 +1,15 @@ +FROM python:3.10-slim + +RUN apt-get update && apt-get install gcc g++ git make -y && apt-get clean \ + && rm -rf /var/lib/apt/lists/* +RUN useradd -m -u 1000 user +USER user +ENV HOME=/home/user \ + PATH=/home/user/.local/bin:$PATH + +WORKDIR $HOME/app + +COPY --chown=user . $HOME/app + +RUN pip install langflow>==0.0.86 -U --user +CMD ["python", "-m", "langflow", "run", "--host", "0.0.0.0", "--port", "7860"] diff --git a/src/frontend/Dockerfile b/src/frontend/Dockerfile index 024eab562..612af5314 100644 --- a/src/frontend/Dockerfile +++ b/src/frontend/Dockerfile @@ -1,16 +1,26 @@ -FROM node:20-alpine as frontend_build +#baseline +FROM --platform=linux/amd64 node:19-bullseye-slim AS base +RUN mkdir -p /home/node/app +RUN chown -R node:node /home/node && chmod -R 770 /home/node +RUN apt-get update && apt-get install -y jq +WORKDIR /home/node/app + +# client build +FROM base AS builder-client ARG BACKEND_URL -WORKDIR /app +ENV BACKEND_URL $BACKEND_URL +RUN echo "BACKEND_URL: $BACKEND_URL" -COPY ./package.json ./package-lock.json ./tsconfig.json ./vite.config.ts ./index.html ./tailwind.config.js ./postcss.config.js ./prettier.config.js /app/ -RUN npm install -COPY ./src /app/src -RUN npm run build +WORKDIR /home/node/app +COPY --chown=node:node . ./ -FROM nginx -COPY --from=frontend_build /app/build/ /usr/share/nginx/html -COPY /nginx.conf /etc/nginx/conf.d/default.conf -COPY start-nginx.sh /start-nginx.sh -RUN chmod +x /start-nginx.sh -ENV BACKEND_URL=$BACKEND_URL -CMD ["/start-nginx.sh"] \ No newline at end of file +COPY ./set_proxy.sh . +RUN chmod +x set_proxy.sh && \ + cat set_proxy.sh | tr -d '\r' > set_proxy_unix.sh && \ + chmod +x set_proxy_unix.sh && \ + ./set_proxy_unix.sh + +USER node + +RUN npm install --loglevel warn +CMD ["npm", "run", "dev:docker"] \ No newline at end of file diff --git a/src/frontend/dev.Dockerfile b/src/frontend/dev.Dockerfile deleted file mode 100644 index 8678b02dd..000000000 --- a/src/frontend/dev.Dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -#baseline -FROM node:19-bullseye-slim AS base -RUN mkdir -p /home/node/app -RUN chown -R node:node /home/node && chmod -R 770 /home/node -RUN apt-get update && apt-get install -y jq -WORKDIR /home/node/app - -# client build -FROM base AS builder-client -ARG BACKEND_URL -ENV BACKEND_URL $BACKEND_URL -RUN echo "BACKEND_URL: $BACKEND_URL" - -WORKDIR /home/node/app -COPY --chown=node:node . ./ - -COPY ./set_proxy.sh . -RUN chmod +x set_proxy.sh && \ - cat set_proxy.sh | tr -d '\r' > set_proxy_unix.sh && \ - chmod +x set_proxy_unix.sh && \ - ./set_proxy_unix.sh - -USER node - -RUN npm install --loglevel warn -CMD ["npm", "run", "dev:docker"] \ No newline at end of file diff --git a/src/frontend/prod.Dockerfile b/src/frontend/prod.Dockerfile new file mode 100644 index 000000000..024eab562 --- /dev/null +++ b/src/frontend/prod.Dockerfile @@ -0,0 +1,16 @@ +FROM node:20-alpine as frontend_build +ARG BACKEND_URL +WORKDIR /app + +COPY ./package.json ./package-lock.json ./tsconfig.json ./vite.config.ts ./index.html ./tailwind.config.js ./postcss.config.js ./prettier.config.js /app/ +RUN npm install +COPY ./src /app/src +RUN npm run build + +FROM nginx +COPY --from=frontend_build /app/build/ /usr/share/nginx/html +COPY /nginx.conf /etc/nginx/conf.d/default.conf +COPY start-nginx.sh /start-nginx.sh +RUN chmod +x /start-nginx.sh +ENV BACKEND_URL=$BACKEND_URL +CMD ["/start-nginx.sh"] \ No newline at end of file