From e88e564124a2e25bbbcdbd635edfcdf8bfaf7fc4 Mon Sep 17 00:00:00 2001 From: nai-degen Date: Sun, 4 Jun 2023 11:16:53 -0500 Subject: [PATCH] adds working alpine Dockerfile for CI --- docker/ci/Dockerfile | 45 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 docker/ci/Dockerfile diff --git a/docker/ci/Dockerfile b/docker/ci/Dockerfile new file mode 100644 index 0000000..cfcb61d --- /dev/null +++ b/docker/ci/Dockerfile @@ -0,0 +1,45 @@ +# Switched to alpine both for smaller image size and because zeromq.js provides +# a working prebuilt binary for alpine. On Debian, the prebuild was not working +# and a bug in libzmq's makefile was causing the build from source to fail. +# https://github.com/zeromq/zeromq.js/issues/529#issuecomment-1370721089 +FROM node:18-alpine as builder + +# Install general build dependencies +RUN apk add --no-cache autoconf automake g++ libtool zeromq-dev python3 \ + py3-pip git curl cmake gcc musl-dev pkgconfig openssl-dev + +# Install Rust (required to build tokenizers) +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y +ENV PATH="/root/.cargo/bin:${PATH}" + +RUN git clone -b tokenize https://gitgud.io/khanon/oai-reverse-proxy.git /app +WORKDIR /app + +RUN npm ci + +RUN npm run build && \ + npm prune --production + +FROM node:18-alpine as runner + +RUN apk add --no-cache \ + zeromq-dev \ + python3 + +COPY --from=builder /app/build /app/build +COPY --from=builder /app/node_modules /app/node_modules +COPY --from=builder /app/.venv /app/.venv +COPY --from=builder /app/package.json /app/package.json + +WORKDIR /app +RUN . .venv/bin/activate + +EXPOSE 7860 + +ENV NODE_ENV=production + +# TODO: stamp with tag and git commit +ENV RENDER=true +ENV RENDER_GIT_COMMIT=ci-test + +CMD [ "npm", "start" ]