Skip to content

Commit

Permalink
fix: pm2 runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed May 3, 2024
1 parent 62cca1e commit c901114
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
26 changes: 9 additions & 17 deletions deployment/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,36 @@
# built for the fuel-explorer
FROM node:20-slim AS base

# Setup environment variables
# Expose the ENVs to the env of the container
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"

ENV SERVER_PORT="${SERVER_PORT:-3004}"
ENV FUEL_PROVIDER="${FUEL_PROVIDER:-https://beta-5.fuel.network/graphql}"
ENV SERVER_BUILD="${SERVER_BUILD}"
ENV SYNC_MISSING="${SYNC_MISSING}"
ENV DB_MIGRATE="${DB_MIGRATE}"

# Database config
ENV DB_HOST="${DB_HOST}"
ENV DB_PORT="${DB_PORT}"
ENV DB_USER="${DB_USER}"
ENV DB_PASS="${DB_PASS}"
ENV DB_NAME="${DB_NAME}"
ENV PM2_HOME=/app-explorer/.pm2

# Enable pnpm using corepack from node.js
# Enable pnpm using corepack form node.js
RUN corepack enable

# Create a non-privileged user
RUN useradd -m fuel

# Copy application code
# Install dependencies for the entire monorepo
COPY . /app-explorer

# Change ownership of the app-explorer to the non-privileged user
RUN chown -R fuel:fuel /app-explorer
WORKDIR /app-explorer
ENV PM2_HOME=/app-explorer/.pm2

# Install dependencies for the entire monorepo
WORKDIR /app-explorer
RUN pnpm install
RUN pnpm db:setup
RUN pnpm add -g pm2 tsx

# Expose the specified port
EXPOSE ${SERVER_PORT}

# Switch to non-privileged user
USER fuel

WORKDIR /app-explorer
CMD ["/app-explorer/scripts/run.sh"]

2 changes: 1 addition & 1 deletion packages/graphql/scripts/run.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

pnpm db:clean && pnpm db:migrate && pnpm server:start
pnpm db:clean && pnpm db:migrate && pm2-runtime ecosystem.config.mjs

0 comments on commit c901114

Please sign in to comment.