Skip to content

Commit 4abcaab

Browse files
committed
Revert
1 parent bfec3c6 commit 4abcaab

2 files changed

Lines changed: 53 additions & 194 deletions

File tree

.github/workflows/pipeline.yml

Lines changed: 48 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -1,174 +1,80 @@
1-
# name: CI/CD pipeline for the eventify API
2-
3-
# on:
4-
# push:
5-
# branches:
6-
# - master
7-
# pull_request:
8-
# branches:
9-
# - master
10-
11-
# jobs:
12-
# build-and-test:
13-
# runs-on: ubuntu-latest
14-
15-
# steps:
16-
# # Checkout code from the repository
17-
# - name: Checkout code
18-
# uses: actions/checkout@v3
19-
20-
# # Set up Node.js environment
21-
# - name: Set up Node.js
22-
# uses: actions/setup-node@v3
23-
# with:
24-
# node-version: '20'
25-
26-
# # Install dependencies
27-
# - name: Install dependencies
28-
# run: npm install
29-
30-
# # Create .env file
31-
# - name: Create .env file
32-
# run: |
33-
# echo ${{ secrets.PORT }} > .env
34-
# echo ${{ secrets.MONGO_ATLAS_URI }} >> .env
35-
# echo ${{ secrets.MAIL_HOST }} >> .env
36-
# echo ${{ secrets.MAIL_PORT }} >> .env
37-
# echo ${{ secrets.MAIL_USER }} >> .env
38-
# echo ${{ secrets.MAIL_PASSWORD }} >> .env
39-
# echo ${{ secrets.JWT_SECRET }} >> .env
40-
# echo ${{ secrets.JWT_REFRESH_SECRET }} >> .env
41-
# echo ${{ secrets.JWT_EXPIRES_IN }} >> .env
42-
# echo ${{ secrets.JWT_REFRESH_TOKEN_EXPIRES_IN }} >> .env
43-
# echo ${{ secrets.JWT_ACCESS_EXPIRES_IN }} >> .env
44-
45-
# # Run tests
46-
# - name: Run unit tests
47-
# run: npm test
48-
49-
# dockerize:
50-
# runs-on: ubuntu-latest
51-
# needs: build-and-test
52-
53-
# steps:
54-
# # Checkout code from the repository
55-
# - name: Checkout code
56-
# uses: actions/checkout@v3
57-
58-
# # Set up Docker Buildx
59-
# - name: Set up Docker Buildx
60-
# uses: docker/setup-buildx-action@v2
61-
62-
# # Log in to Docker Hub
63-
# - name: Log in to Docker Hub
64-
# uses: docker/login-action@v2
65-
# with:
66-
# username: ${{ secrets.DOCKER_USERNAME }}
67-
# password: ${{ secrets.DOCKER_PASSWORD }}
68-
69-
# # Build And Push Docker image
70-
# - name: Build and push Docker image
71-
# uses: docker/build-push-action@v4
72-
# with:
73-
# context: .
74-
# push: true
75-
# tags: ${{ secrets.DOCKER_USERNAME }}/eventify-api:latest
76-
77-
# # Log out from Docker Hub
78-
# - name: Log out from Docker Hub
79-
# run: docker logout
80-
811
name: CI/CD pipeline for the eventify API
822

833
on:
844
push:
85-
branches: [ master ]
5+
branches:
6+
- master
867
pull_request:
87-
branches: [ master ]
8+
branches:
9+
- master
8810

8911
jobs:
9012
build-and-test:
9113
runs-on: ubuntu-latest
92-
env:
93-
NODE_ENV: test
94-
NODE_OPTIONS: --max-old-space-size=256
14+
9515
steps:
96-
- name: Checkout
97-
uses: actions/checkout@v4
16+
# Checkout code from the repository
17+
- name: Checkout code
18+
uses: actions/checkout@v3
9819

99-
- name: Use Node.js 20.x
100-
uses: actions/setup-node@v4
20+
# Set up Node.js environment
21+
- name: Set up Node.js
22+
uses: actions/setup-node@v3
10123
with:
10224
node-version: '20'
103-
cache: 'npm'
104-
105-
- name: Install deps (CI)
106-
run: npm ci
107-
108-
# If your unit tests need env vars, write them as KEY=VALUE lines.
109-
# (What you had before wrote only values, which doesn't work.)
110-
- name: Create .env for tests
111-
run: |
112-
{
113-
echo "PORT=${{ secrets.PORT }}"
114-
echo "MONGO_URI=${{ secrets.MONGO_ATLAS_URI }}"
115-
echo "MAIL_HOST=${{ secrets.MAIL_HOST }}"
116-
echo "MAIL_PORT=${{ secrets.MAIL_PORT }}"
117-
echo "MAIL_USER=${{ secrets.MAIL_USER }}"
118-
echo "MAIL_PASSWORD=${{ secrets.MAIL_PASSWORD }}"
119-
echo "JWT_SECRET=${{ secrets.JWT_SECRET }}"
120-
echo "JWT_REFRESH_SECRET=${{ secrets.JWT_REFRESH_SECRET }}"
121-
echo "JWT_EXPIRES_IN=${{ secrets.JWT_EXPIRES_IN }}"
122-
echo "JWT_REFRESH_TOKEN_EXPIRES_IN=${{ secrets.JWT_REFRESH_TOKEN_EXPIRES_IN }}"
123-
echo "JWT_ACCESS_EXPIRES_IN=${{ secrets.JWT_ACCESS_EXPIRES_IN }}"
124-
} > .env
12525

126-
- name: TypeScript build (ensure dist exists)
127-
run: npm run build
128-
129-
- name: Run unit tests (reduced workers to avoid OOM)
130-
run: npm test -- --runInBand --maxWorkers=50%
26+
# Install dependencies
27+
- name: Install dependencies
28+
run: npm install
29+
30+
# Create .env file
31+
- name: Create .env file
32+
run: |
33+
echo ${{ secrets.PORT }} > .env
34+
echo ${{ secrets.MONGO_ATLAS_URI }} >> .env
35+
echo ${{ secrets.MAIL_HOST }} >> .env
36+
echo ${{ secrets.MAIL_PORT }} >> .env
37+
echo ${{ secrets.MAIL_USER }} >> .env
38+
echo ${{ secrets.MAIL_PASSWORD }} >> .env
39+
echo ${{ secrets.JWT_SECRET }} >> .env
40+
echo ${{ secrets.JWT_REFRESH_SECRET }} >> .env
41+
echo ${{ secrets.JWT_EXPIRES_IN }} >> .env
42+
echo ${{ secrets.JWT_REFRESH_TOKEN_EXPIRES_IN }} >> .env
43+
echo ${{ secrets.JWT_ACCESS_EXPIRES_IN }} >> .env
44+
45+
# Run tests
46+
- name: Run unit tests
47+
run: npm test
13148

13249
dockerize:
13350
runs-on: ubuntu-latest
13451
needs: build-and-test
135-
permissions:
136-
contents: read
137-
packages: write
52+
13853
steps:
139-
- name: Checkout
140-
uses: actions/checkout@v4
54+
# Checkout code from the repository
55+
- name: Checkout code
56+
uses: actions/checkout@v3
14157

58+
# Set up Docker Buildx
14259
- name: Set up Docker Buildx
143-
uses: docker/setup-buildx-action@v3
60+
uses: docker/setup-buildx-action@v2
14461

62+
# Log in to Docker Hub
14563
- name: Log in to Docker Hub
146-
uses: docker/login-action@v3
64+
uses: docker/login-action@v2
14765
with:
14866
username: ${{ secrets.DOCKER_USERNAME }}
14967
password: ${{ secrets.DOCKER_PASSWORD }}
15068

151-
# Optional: Add metadata (labels, semver tags, sha)
152-
- name: Docker meta
153-
id: meta
154-
uses: docker/metadata-action@v5
155-
with:
156-
images: ${{ secrets.DOCKER_USERNAME }}/eventify-api
157-
tags: |
158-
type=raw,value=latest
159-
type=sha
160-
161-
- name: Build and push (prod stage)
162-
uses: docker/build-push-action@v6
69+
# Build And Push Docker image
70+
- name: Build and push Docker image
71+
uses: docker/build-push-action@v4
16372
with:
16473
context: .
16574
push: true
166-
target: prod # <- uses the prod stage from the Dockerfile I provided
167-
platforms: linux/amd64
168-
tags: ${{ steps.meta.outputs.tags }}
169-
labels: ${{ steps.meta.outputs.labels }}
170-
cache-from: type=gha
171-
cache-to: type=gha,mode=max
75+
tags: ${{ secrets.DOCKER_USERNAME }}/eventify-api:latest
17276

173-
- name: Logout Docker Hub
77+
# Log out from Docker Hub
78+
- name: Log out from Docker Hub
17479
run: docker logout
80+

dockerfile

Lines changed: 5 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,13 @@
1-
# FROM node:20.7.0
1+
FROM node:20.7.0
22

3-
# WORKDIR /usr/src/app
4-
5-
# COPY package*.json ./
6-
7-
# RUN npm install
8-
9-
# COPY . .
10-
11-
# EXPOSE 3000
12-
13-
# CMD [ "npm", "run", "start" ]
14-
15-
# -------------------------------------------------------
16-
# Base image (pin to the current version)
17-
# -------------------------------------------------------
18-
FROM node:20.7.0 AS base
193
WORKDIR /usr/src/app
204

21-
# -------------------------------------------------------
22-
# Dev stage (keeps the old behavior, uses ts-node/nest)
23-
# -------------------------------------------------------
24-
FROM base AS dev
25-
COPY package*.json ./
26-
RUN npm ci
27-
COPY . .
28-
EXPOSE 3000
29-
CMD ["npm","run","start:dev"]
30-
31-
# -------------------------------------------------------
32-
# Build stage (compile to dist/, then prune dev deps)
33-
# -------------------------------------------------------
34-
FROM base AS build
355
COPY package*.json ./
36-
# Keep devDependencies for the build (nest/tsc)
37-
RUN npm ci
38-
COPY . .
39-
RUN npm run build \
40-
&& npm prune --omit=dev
41-
42-
# -------------------------------------------------------
43-
# Production runtime (small, stable, Railway-friendly)
44-
# -------------------------------------------------------
45-
FROM node:20.7.0 AS prod
46-
WORKDIR /usr/src/app
47-
ENV NODE_ENV=production
48-
# Cap heap to avoid OOM on free tiers
49-
ENV NODE_OPTIONS="--max-old-space-size=256"
506

51-
# Install only runtime deps
52-
COPY package*.json ./
53-
RUN npm ci --omit=dev
7+
RUN npm install
548

55-
# Bring compiled app
56-
COPY --from=build /usr/src/app/dist ./dist
9+
COPY . .
5710

5811
EXPOSE 3000
59-
# Same path Railway tried to run; now it exists.
60-
CMD ["node","dist/main.js"]
12+
13+
CMD [ "npm", "run", "start" ]

0 commit comments

Comments
 (0)