Skip to content

Commit

Permalink
ci(deployment): add deploy.yml for GitHub Actions and Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
naimulcsx committed Nov 19, 2024
1 parent 1952b44 commit 25d7d47
Show file tree
Hide file tree
Showing 7 changed files with 1,083 additions and 39 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build & Deploy

on:
push:
branches: ['233-migrate-to-remix']

pull_request:
branches: ['233-migrate-to-remix']

jobs:
build-and-deploy:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]

steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npx nx build web
- run: npm run build --if-present

- uses: a7ul/tar-action@v1.1.0
with:
command: c
cwd: './'
files: |
dist/apps/web/
outPath: deploy.tar

- name: Deploy App to CapRover
uses: caprover/deploy-from-github@v1.0.1
with:
server: '${{ secrets.CAPROVER_SERVER }}'
app: '${{ secrets.APP_NAME }}'
token: '${{ secrets.APP_TOKEN }}'
41 changes: 41 additions & 0 deletions apps/web/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM node:20.16.0-alpine

# Set working directory
WORKDIR /app

# Copy build files
COPY build/client ./client
COPY build/server ./server

# Create server.js file
RUN echo "import { createRequestHandler } from '@remix-run/express'; \
import express from 'express'; \
import * as build from './server/index.js'; \
\
const app = express(); \
const port = process.env.PORT || 3380; \
\
app.use(express.static('./client')); \
\
app.all( \
'*', \
createRequestHandler({ \
build, \
}), \
); \
\
app.listen(port, () => { \
console.log(\`Server is running on port \${port}\`); \
});" > server.js

# Copy package files
COPY build/server/package.json ./

# Install production dependencies only
RUN npm install

# Expose port from environment variable with fallback
EXPOSE 3380

# Start the server
CMD ["node", "server.js"]
4 changes: 4 additions & 0 deletions apps/web/captain-definition
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"schemaVersion": 2,
"dockerfilePath": "./apps/web/Dockerfile"
}
19 changes: 19 additions & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@
"scripts": {},
"type": "module",
"dependencies": {
"@mantine/charts": "^7.14.1",
"@mantine/core": "^7.14.1",
"@mantine/dates": "^7.14.1",
"@mantine/hooks": "^7.14.1",
"@mantine/modals": "^7.14.1",
"@mantine/notifications": "^7.14.1",
"@mantine/spotlight": "^7.14.1",
"bcryptjs": "^2.4.3",
"dayjs": "^1.11.13",
"dotenv": "^16.4.5",
"drizzle-orm": "^0.36.3",
"hugeicons-react": "^0.3.0",
"nprogress": "^0.2.0",
"postgres": "^3.4.5",
"recharts": "^2.13.3",
"remix-auth": "^3.7.0",
"remix-auth-form": "^1.5.0",
"tailwind-preset-mantine": "^1.3.0",
"zod": "^3.23.8",
"@remix-run/node": "^2.14.0",
"@remix-run/react": "^2.14.0",
"@remix-run/serve": "^2.14.0",
Expand Down
Loading

0 comments on commit 25d7d47

Please sign in to comment.