diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..dff8814 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +.git +.next +node_modules +.env* +.cursor +.github +*.log +npm-debug.log* +dev.Dockerfile +.drone.yml +README.md diff --git a/.drone.yml b/.drone.yml index c8dec6a..db48fff 100644 --- a/.drone.yml +++ b/.drone.yml @@ -13,8 +13,18 @@ steps: - 'git config --global url."https://github.com/".insteadOf git@github.com:' - "git submodule update --recursive" - name: build and publish - image: plugins/docker + image: plugins/docker:21 + environment: + BUILDX_NO_DEFAULT_ATTESTATIONS: "1" + depends_on: + - submodules settings: + platform: linux/amd64 + base_image_registry: dhi.io + base_image_username: + from_secret: dockerhub_username + base_image_password: + from_secret: dockerhub_password registry: registry.dev.kern.ai username: from_secret: docker_username @@ -75,8 +85,18 @@ steps: - 'git config --global url."https://github.com/".insteadOf git@github.com:' - "git submodule update --recursive" - name: build and publish - image: plugins/docker + image: plugins/docker:21 + environment: + BUILDX_NO_DEFAULT_ATTESTATIONS: "1" + depends_on: + - submodules settings: + platform: linux/arm64 + base_image_registry: dhi.io + base_image_username: + from_secret: dockerhub_username + base_image_password: + from_secret: dockerhub_password registry: registry.dev.kern.ai username: from_secret: docker_username @@ -110,13 +130,23 @@ steps: - 'git config --global url."https://github.com/".insteadOf git@github.com:' - "git submodule update --recursive" - name: build and publish - image: plugins/docker + image: plugins/docker:21 + environment: + BUILDX_NO_DEFAULT_ATTESTATIONS: "1" + depends_on: + - submodules settings: + base_image_registry: dhi.io + base_image_username: + from_secret: dockerhub_username + base_image_password: + from_secret: dockerhub_password username: from_secret: dockerhub_username password: from_secret: dockerhub_password repo: "kernai/${DRONE_REPO_NAME}" + platform: linux/amd64 tag: "${DRONE_TAG}-drone-amd64" trigger: @@ -139,13 +169,23 @@ steps: - 'git config --global url."https://github.com/".insteadOf git@github.com:' - "git submodule update --recursive" - name: build and publish - image: plugins/docker + image: plugins/docker:21 + environment: + BUILDX_NO_DEFAULT_ATTESTATIONS: "1" + depends_on: + - submodules settings: + base_image_registry: dhi.io + base_image_username: + from_secret: dockerhub_username + base_image_password: + from_secret: dockerhub_password username: from_secret: dockerhub_username password: from_secret: dockerhub_password repo: "kernai/${DRONE_REPO_NAME}" + platform: linux/arm64 tag: "${DRONE_TAG}-drone-arm64" trigger: @@ -173,4 +213,4 @@ depends_on: trigger: event: - - tag \ No newline at end of file + - tag diff --git a/Dockerfile b/Dockerfile index 5370d18..da1db55 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,39 @@ -FROM node:18-alpine AS build +ARG DHI_NODE_BUILD=dhi.io/node:20-debian12-dev +ARG DHI_NODE_RUNTIME=dhi.io/node:20-debian12 + +FROM ${DHI_NODE_BUILD} AS builder WORKDIR /app -COPY package*.json /app/ -RUN npm install -COPY . /app + +COPY package*.json ./ +ENV NEXT_TELEMETRY_DISABLED=1 +RUN npm install && npm cache clean --force + +COPY pages ./pages +COPY pkg ./pkg +COPY util ./util +COPY styles ./styles +COPY i18n ./i18n +COPY public ./public +COPY submodules ./submodules +COPY next.config.js . +COPY tsconfig.json . +COPY postcss.config.js . +COPY tailwind.config.js . + RUN npm run build -ENTRYPOINT ["/usr/local/bin/npm", "run", "start"] \ No newline at end of file +FROM ${DHI_NODE_RUNTIME} + +WORKDIR /app + +ENV NODE_ENV=production +ENV NEXT_TELEMETRY_DISABLED=1 + +COPY --from=builder --chown=1000:1000 /app/.next/standalone ./ +COPY --from=builder --chown=1000:1000 /app/public ./public +COPY --from=builder --chown=1000:1000 /app/.next/static ./.next/static + +USER node + +ENTRYPOINT ["node", "server.js"] diff --git a/dev.Dockerfile b/dev.Dockerfile index 257cbb8..6493ff2 100644 --- a/dev.Dockerfile +++ b/dev.Dockerfile @@ -1,9 +1,13 @@ -FROM node:18-alpine +ARG PARENT_IMAGE=dhi.io/node:20-debian12-dev + +FROM ${PARENT_IMAGE} WORKDIR /app VOLUME ["/app"] +USER root + COPY package*.json /app/ ENV NEXT_TELEMETRY_DISABLED=1 @@ -12,4 +16,4 @@ ENV WATCHPACK_POLLING=true RUN npm install --include=dev -ENTRYPOINT ["/usr/local/bin/npm", "run", "dev"] \ No newline at end of file +ENTRYPOINT ["/usr/local/bin/npm", "run", "dev"] diff --git a/next.config.js b/next.config.js index 22dd8c1..5687959 100644 --- a/next.config.js +++ b/next.config.js @@ -1,5 +1,6 @@ /** @type {import('next').NextConfig} */ const nextConfig = { + output: 'standalone', reactStrictMode: true, swcMinify: true, env: { diff --git a/submodules/javascript-functions b/submodules/javascript-functions index 4850e39..60f9eeb 160000 --- a/submodules/javascript-functions +++ b/submodules/javascript-functions @@ -1 +1 @@ -Subproject commit 4850e39785215aa8cabcb1cd7df0cd47681be0d5 +Subproject commit 60f9eeba39b3188eee0a48bfca756296c57dfeda diff --git a/submodules/react-components b/submodules/react-components index 99e54d6..37dbcb4 160000 --- a/submodules/react-components +++ b/submodules/react-components @@ -1 +1 @@ -Subproject commit 99e54d67a477fa59655f93a21b8568659903e6c0 +Subproject commit 37dbcb486d1fe2eaf27b79cd23fc0644b8b7b24d