Skip to content

feat: Add a Dockerfile for Bun server #387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ indent_size = unset

# Ignore paths
[{.git/**/*,**/*.lock,**/Move.toml,LICENSE,**/*.html,**/*.css,**/*.json,portal/pnpm-lock.yaml,
c4/**/*}]
c4/**/*,Dockerfile}]
charset = unset
end_of_line = unset
indent_size = unset
Expand Down
16 changes: 16 additions & 0 deletions portal/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
node_modules
Dockerfile*
docker-compose*
.dockerignore
.git
.gitignore
README.md
LICENSE
.vscode
Makefile
helm-charts
.env
.editorconfig
.idea
coverage*
.next/
53 changes: 53 additions & 0 deletions portal/docker/server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# use the official Bun image
# see all versions at https://hub.docker.com/r/oven/bun/tags
FROM oven/bun:1 AS base
WORKDIR /usr/src/app

# environment variables, can be overridden by docker build --build-arg <arg>=<value>
ARG ENABLE_ALLOWLIST="false"
ENV ENABLE_ALLOWLIST=${ENABLE_ALLOWLIST}

ARG ENABLE_BLOCKLIST="false"
ENV ENABLE_BLOCKLIST=${ENABLE_BLOCKLIST}

ARG ENABLE_SENTRY="false"
ENV ENABLE_SENTRY=${ENABLE_SENTRY}

ARG LANDING_PAGE_OID_B36="41qecxqcyzqm8gl0cp2fqd6iq62j0jo5the39nb0bsg39acnib"
ENV LANDING_PAGE_OID_B36=${LANDING_PAGE_OID_B36}

ARG PORTAL_DOMAIN_NAME_LENGTH="21"
ENV PORTAL_DOMAIN_NAME_LENGTH=${PORTAL_DOMAIN_NAME_LENGTH}

ARG PREMIUM_RPC_URL_LIST="https://fullnode.testnet.sui.io"
ENV PREMIUM_RPC_URL_LIST=${PREMIUM_RPC_URL_LIST}

ARG RPC_URL_LIST="https://fullnode.testnet.sui.io,https://testnet.suiet.app"
ENV RPC_URL_LIST=${RPC_URL_LIST}

ARG SUINS_CLIENT_NETWORK="testnet"
ENV SUINS_CLIENT_NETWORK=${SUINS_CLIENT_NETWORK}

# install dependencies into temp directory
# this will cache them and speed up future builds
FROM base AS install
RUN mkdir -p /temp/prod
COPY portal/package.json portal/bun.lock /temp/prod/
COPY portal/common /temp/prod/common
COPY portal/server /temp/prod/server
COPY portal/worker /temp/prod/worker
RUN cd /temp/prod && bun install --frozen-lockfile
RUN cd /temp/prod && bun run build:server

# copy production dependencies and source code into final image
FROM base AS release
COPY --from=install /temp/prod/node_modules node_modules
COPY --from=install /temp/prod/package.json .
COPY --from=install /temp/prod/server/package.json server/package.json
COPY --from=install /temp/prod/server/.next server/.next

# run the app
USER bun
EXPOSE 3000/tcp
ENV NODE_ENV=production
CMD [ "bun", "run", "server:prod" ]
3 changes: 2 additions & 1 deletion portal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"build:worker": "bun -F worker build:prod",
"worker": "bun -F worker serve:prod",
"build:server": "bun -F server build",
"server": "bun -F server start"
"server": "bun -F server start",
"server:prod": "bun -F server start:prod"
}
}
1 change: 0 additions & 1 deletion portal/server/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

/// <reference types="next" />
/// <reference types="next/image-types/global" />

Expand Down
3 changes: 2 additions & 1 deletion portal/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
"start": "next start",
"start:prod": "next start -H 0.0.0.0 -p 3000"
},
"dependencies": {
"@sentry/nextjs": "^8",
Expand Down