Skip to content
Open
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
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,27 @@ npm run dev:backend

API: http://localhost:3001 (health: http://localhost:3001/health, v1: http://localhost:3001/api/v1).

#### Run backend with Docker

```bash
# from repository root
docker build -f backend/Dockerfile -t trivela-backend .

docker run --rm -p 3001:3001 \
-e PORT=3001 \
-e STELLAR_NETWORK=testnet \
-e SOROBAN_RPC_URL=https://soroban-testnet.stellar.org \
-e CORS_ALLOWED_ORIGINS=http://localhost:5173 \
-e TRIVELA_API_KEY=dev-secret \
trivela-backend
```

or using an env file:

```bash
docker run --rm -p 3001:3001 --env-file backend/.env trivela-backend
```

### 4. Run frontend

```bash
Expand Down
8 changes: 8 additions & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules
npm-debug.log
Dockerfile
.dockerignore
.git
.gitignore
*.md
.vscode
17 changes: 15 additions & 2 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
FROM node:20-alpine AS base
# Backend Dockerfile
# Build and run the Node.js Express API in a small, production-ready image

FROM node:20-alpine AS builder
WORKDIR /app

# Copy package files and install dependencies (production only)
COPY backend/package*.json ./
RUN npm ci --omit=dev

COPY backend/src ./src
# Copy source and non-code assets
COPY backend/ ./

# Optional step if your code pipeline has a build step
# RUN npm run build

FROM node:20-alpine AS runtime
WORKDIR /app

COPY --from=builder /app ./

ENV NODE_ENV=production
ENV PORT=3001

EXPOSE 3001

CMD ["node", "src/server.js"]

14 changes: 14 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ Build image from repo root:
docker build -f backend/Dockerfile -t trivela-backend .
```

Or build using backend as context (recommended for isolation):

```bash
docker build -f backend/Dockerfile -t trivela-backend backend/
```

Run container (example):

```bash
Expand All @@ -141,3 +147,11 @@ docker run --rm -p 3001:3001 \
-e TRIVELA_API_KEY=dev-secret \
trivela-backend
```

You can also use an env file:

```bash
docker run --rm -p 3001:3001 --env-file backend/.env \
trivela-backend
```