From 080266409e415c54427fd0ff3ccc041da9f1e852 Mon Sep 17 00:00:00 2001 From: Craig Barnes Date: Tue, 10 Dec 2024 23:25:13 -0500 Subject: [PATCH] update Docker file, add start.sh (#11) --- Dockerfile | 58 ++++++++++++++++++++++++++++++++---------------------- start.sh | 2 +- 2 files changed, 35 insertions(+), 25 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7266bc2..753f7ab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,33 +1,43 @@ -# docker build -t brhff . -# docker run -p 3000:3000 -it brhff -# Build stage -FROM node:20-slim AS builder +# docker build -t gen3ff . +# docker run -p 3000:3000 -it gen3ff +# for Macbook silicon M1/m2 uncomment the following lines and comment quay.io/cdis/ubuntu:20.04: +#FROM arm64v8/ubuntu:20.04 as build -ARG NEXT_PUBLIC_PORTAL_BASENAME +FROM quay.io/cdis/ubuntu:20.04 AS build -WORKDIR /gen3 - -COPY ./package.json ./package-lock.json ./next.config.js ./tsconfig.json ./.env.development ./tailwind.config.js ./postcss.config.js ./start.sh ./ -RUN npm ci -COPY ./src ./src -COPY ./public ./public -COPY ./config ./config -RUN npm install @swc/core @napi-rs/magic-string && \ - npm run build +ARG NODE_VERSION=20 +ARG NEXT_PUBLIC_PORTAL_BASENAME=/ff -# Production stage -FROM node:20-slim AS runner +ENV NPM_CONFIG_PREFIX=/home/node/.npm-global +ENV PATH=$PATH:/home/node/.npm-global/bin WORKDIR /gen3 -RUN addgroup --system --gid 1001 nextjs && \ - adduser --system --uid 1001 nextjs -USER nextjs -COPY --from=builder --chown=nextjs:nextjs /gen3/start.sh ./ -COPY --from=builder --chown=nextjs:nextjs /gen3/config ./config -COPY --from=builder --chown=nextjs:nextjs /gen3/public ./public -COPY --from=builder --chown=nextjs:nextjs /gen3/.next/standalone ./ -COPY --from=builder --chown=nextjs:nextjs /gen3/.next/static ./.next/static +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + libssl1.1 \ + libgnutls30 \ + ca-certificates \ + curl \ + git \ + gnupg \ + && mkdir -p /etc/apt/keyrings \ + && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \ + && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_VERSION.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \ + && apt-get update \ + && apt-get install -y nodejs \ + && apt-get clean \ + && npm install -g npm@10.5.2 +RUN addgroup --system --gid 1001 nextjs && adduser --system --uid 1001 nextjs +COPY ./package.json ./package-lock.json ./next.config.js ./tsconfig.json ./tailwind.config.js ./postcss.config.js ./start.sh ./ +COPY ./src ./src +COPY ./public ./public +COPY ./config ./config +RUN npm ci +RUN npm install \ + "@swc/core" \ + "@napi-rs/magic-string" +RUN npm run build ENV PORT=3000 CMD bash ./start.sh diff --git a/start.sh b/start.sh index debcc76..5cf0f39 100755 --- a/start.sh +++ b/start.sh @@ -2,4 +2,4 @@ set -e echo "starting server" -node server.js +npm run start