diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7855465 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,51 @@ +name: CI/CD + +on: + push: + branches: [main] + pull_request: + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: '18' + cache: 'npm' + - run: npm ci + - run: npm run lint --workspaces --if-present + + test: + runs-on: ubuntu-latest + needs: lint + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: '18' + cache: 'npm' + - run: npm ci + - run: npm test + + build: + runs-on: ubuntu-latest + needs: test + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: '18' + cache: 'npm' + - run: npm ci + - run: npm run build + + deploy: + runs-on: ubuntu-latest + needs: build + if: github.ref == 'refs/heads/main' + steps: + - uses: actions/checkout@v3 + - name: Deploy to staging + run: echo "Deploying to staging..." diff --git a/apps/api/Dockerfile b/apps/api/Dockerfile new file mode 100644 index 0000000..6b717dd --- /dev/null +++ b/apps/api/Dockerfile @@ -0,0 +1,11 @@ +FROM node:18-alpine +WORKDIR /app +COPY package*.json ./ +COPY turbo.json ./ +COPY apps/api/package.json ./apps/api/package.json +COPY apps/web/package.json ./apps/web/package.json +COPY packages/types/package.json ./packages/types/package.json +RUN npm install +COPY . +EXPOSE 3001 +CMD ["npm", "start", "--workspace=@fircle/api"] diff --git a/apps/web/Dockerfile b/apps/web/Dockerfile new file mode 100644 index 0000000..6a86ad3 --- /dev/null +++ b/apps/web/Dockerfile @@ -0,0 +1,12 @@ +FROM node:18-alpine +WORKDIR /app +COPY package*.json ./ +COPY turbo.json ./ +COPY apps/web/package.json ./apps/web/package.json +COPY apps/api/package.json ./apps/api/package.json +COPY packages/types/package.json ./packages/types/package.json +RUN npm install +COPY . +RUN npm run build --workspace=@fircle/web +EXPOSE 3000 +CMD ["npm", "start", "--workspace=@fircle/web"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..71ffa90 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,30 @@ +version: '3.8' +services: + postgres: + image: postgres:15 + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: fircle + ports: + - "5432:5432" + api: + build: + context: . + dockerfile: apps/api/Dockerfile + environment: + DATABASE_URL: postgres://postgres:postgres@postgres:5432/fircle + ports: + - "3001:3001" + depends_on: + - postgres + web: + build: + context: . + dockerfile: apps/web/Dockerfile + environment: + API_URL: http://localhost:3001 + ports: + - "3000:3000" + depends_on: + - api