Skip to content

Commit

Permalink
Merge pull request #400 from orochi-network/devops/update_dockerfile
Browse files Browse the repository at this point in the history
Devops: update dockerfile for serverless and new mina-service
  • Loading branch information
dqtkien authored Dec 20, 2024
2 parents 48b6e4a + 488b3e1 commit 147e677
Showing 2 changed files with 18 additions and 9 deletions.
15 changes: 10 additions & 5 deletions packages/mina-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Use our customized image based on Node.js 20 slim image as a base
FROM orochinetwork/node:20-iron AS builder
FROM orochinetwork/node:22-bookworm AS builder

# Create a non-root user and group early in the Dockerfile
RUN groupadd -r appuser && useradd -r -g appuser -s /bin/bash -d /usr/src/app appuser
RUN groupadd -g 1001 appuser && useradd -u 1001 -g appuser -s /bin/bash -d /usr/src/app appuser


# Set the working directory
WORKDIR /usr/src/app
@@ -24,20 +25,24 @@ RUN --mount=type=secret,id=npm,target=/root/.npmrc yarn install --frozen-lockfil
USER appuser

# Build the necessary workspaces
RUN yarn workspace @zkdb/smart-contract build && \
RUN yarn workspace @zkdb/common build && \
yarn workspace @zkdb/permission build && \
yarn workspace @zkdb/smart-contract build && \
yarn workspace @zkdb/storage build && \
yarn workspace @zkdb/mina-service build

# Use our customized image based on Node.js 20 slim image as a runner
FROM orochinetwork/node:20-alpine AS runner
FROM orochinetwork/node:22-bookworm AS runner

# Create a non-root user and group in the runner stage
RUN addgroup -S appuser && adduser -S -G appuser -h /usr/src/app appuser
RUN groupadd -g 1001 appuser && useradd -u 1001 -g appuser -s /bin/bash -d /usr/src/app appuser

# Set the working directory
WORKDIR /usr/src/app

# Copy the built application and node_modules from the builder stage
COPY --from=builder --chown=appuser:appuser /usr/src/app/packages/common /usr/src/app/packages/common
COPY --from=builder --chown=appuser:appuser /usr/src/app/packages/permission /usr/src/app/packages/permission
COPY --from=builder --chown=appuser:appuser /usr/src/app/packages/smart-contract /usr/src/app/packages/smart-contract
COPY --from=builder --chown=appuser:appuser /usr/src/app/packages/storage /usr/src/app/packages/storage
COPY --from=builder --chown=appuser:appuser /usr/src/app/packages/mina-service /usr/src/app/packages/mina-service
12 changes: 8 additions & 4 deletions packages/serverless/Dockerfile
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
FROM orochinetwork/node:20-iron AS builder

# Create a non-root user and group early in the Dockerfile
RUN groupadd -r appuser && useradd -r -g appuser -s /bin/bash -d /usr/src/app appuser
RUN groupadd -g 1001 appuser && useradd -u 1001 -g appuser -s /bin/bash -d /usr/src/app appuser

# Set the working directory
WORKDIR /usr/src/app
@@ -24,21 +24,25 @@ RUN --mount=type=secret,id=npm,target=/root/.npmrc yarn install --frozen-lockfil
USER appuser

# Build the necessary workspaces
RUN yarn workspace @zkdb/smart-contract build && \
RUN yarn workspace @zkdb/common build && \
yarn workspace @zkdb/permission build && \
yarn workspace @zkdb/smart-contract build && \
yarn workspace @zkdb/storage build && \
yarn workspace @zkdb/serverless build


# Use our customized image based on Node.js 20 slim image as a runner
FROM orochinetwork/node:20-alpine AS runner
FROM orochinetwork/node:22-bookworm AS runner

# Create a non-root user and group in the runner stage
RUN addgroup -S appuser && adduser -S -G appuser -h /usr/src/app appuser
RUN groupadd -g 1001 appuser && useradd -u 1001 -g appuser -s /bin/bash -d /usr/src/app appuser

# Set the working directory
WORKDIR /usr/src/app

# Copy the application code and node_modules from the builder stage
COPY --from=builder --chown=appuser:appuser /usr/src/app/packages/common /usr/src/app/packages/common
COPY --from=builder --chown=appuser:appuser /usr/src/app/packages/permission /usr/src/app/packages/permission
COPY --from=builder --chown=appuser:appuser /usr/src/app/packages/smart-contract /usr/src/app/packages/smart-contract
COPY --from=builder --chown=appuser:appuser /usr/src/app/packages/storage /usr/src/app/packages/storage
COPY --from=builder --chown=appuser:appuser /usr/src/app/packages/serverless /usr/src/app/packages/serverless

0 comments on commit 147e677

Please sign in to comment.