Skip to content

Commit

Permalink
fix: Docker config
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Jun 20, 2024
1 parent 9be70bf commit fdbf3a7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 23 deletions.
28 changes: 9 additions & 19 deletions deployment/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,25 @@
# This image contains the graphql server
# built for the fuel-explorer
FROM node:20-slim AS base

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

# We need this to build graphql codegen after PNPM install
ENV FUEL_PROVIDER="$FUEL_PROVIDER"
ARG FUEL_PROVIDER="${FUEL_PROVIDER:-https://testnet.fuel.network/v1/graphql}"

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

# Install dependencies for the entire monorepo
COPY . /app-explorer
WORKDIR /app-explorer

# Install pnpm globally
FROM base AS prod-deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile --ignore-scripts
# Copy the package.json and pnpm-lock.yaml
COPY . /app
WORKDIR /app

# Build libs
FROM base AS build
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile --ignore-scripts
RUN pnpm run build:lib
FROM base AS deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --ignore-scripts

# Copy the built lib into the server
FROM base
COPY --from=prod-deps /app-explorer/node_modules /app-explorer/node_modules
COPY --from=build /app-explorer/dist /app-explorer/dist
COPY --from=build /app-explorer/src/graphql/generated /app-explorer/src/graphql/generated
COPY --from=deps /app/node_modules /app/node_modules
WORKDIR /app

# Expose the specified port
EXPOSE ${SERVER_PORT}
Expand Down
6 changes: 2 additions & 4 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,14 @@ services:
build:
context: ../packages/graphql
dockerfile: ../../deployment/Dockerfile
environment:
- FUEL_PROVIDER=${FUEL_PROVIDER:-http://localhost:4004/v1/graphql}
args:
- FUEL_PROVIDER=${FUEL_PROVIDER:-http://localhost:4000/v1/graphql}
env_file:
- ./envs/global.env
- ./envs/indexer.env
ports:
- "${INDEXER_GRAPHQL_PORT:-3004}:${SERVER_PORT:-3004}"
- "${INDEXER_SYNCER_PORT:-3005}:${SYNCER_PORT:-3005}"
volumes:
- ../packages/graphql:/app
networks:
- app-network

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"author": "Fuel Labs <contact@fuel.sh> (https://fuel.network/)",
"license": "Apache-2.0",
"packageManager": "pnpm@8.1.0",
"engines": {
"node": ">=20.11.0",
"pnpm": ">=8.1.0"
Expand Down
1 change: 1 addition & 0 deletions packages/graphql/scripts/run.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash

echo "Running Server"
pnpm build:lib
pnpm db:setup
pnpm db:migrate
pnpm server:start

0 comments on commit fdbf3a7

Please sign in to comment.