diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..f4da5f5c4f --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +node_modules +.git +.DS_Store +npm-debug.log +yarn-error.log \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..84cf5cdd25 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,46 @@ +name: CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + validate: + name: Validate Source Code + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v5 + + - name: Setup node + uses: actions/setup-node@v5 + with: + node-version: '24' + cache: yarn + cache-dependency-path: '**/yarn.lock' + + - name: Install dependencies + run: yarn install --frozen-lockfile + + - name: Run tests + run: yarn test + + - name: Build Docker image + run: docker compose build + + - name : Run Docker container + run: docker compose up -d + + - name: Notify on success + if: success() + run: echo "CI Pipeline passed successfully!" + + - name: Notify on failure + if: failure() + run: echo "CI Pipeline failed! Please check the logs." diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..6d7c304737 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM node:24-alpine + +WORKDIR /app + +ENV NODE_ENV=production +ENV PORT=3001 + +COPY package.json yarn.lock ./ +RUN yarn install --frozen-lockfile --production=true + +COPY . . + +EXPOSE 3001 + +CMD ["yarn", "start"] \ No newline at end of file diff --git a/app.js b/app.js index 5ab128e4b4..54bf20988d 100644 --- a/app.js +++ b/app.js @@ -4,16 +4,20 @@ const port = process.env.PORT || 3001; app.get("/", (req, res) => res.type('html').send(html)); -const server = app.listen(port, () => console.log(`Example app listening on port ${port}!`)); +function startServer() { + const server = app.listen(port, () => console.log(`Example app listening on port ${port}!`)); -server.keepAliveTimeout = 120 * 1000; -server.headersTimeout = 120 * 1000; + server.keepAliveTimeout = 120 * 1000; + server.headersTimeout = 120 * 1000; + + return server; +} const html = ` - Hello from Render! + Hello from 23521574 - Ngô Quang Tiến!