From 75efaf98c0f00dc8216c856b2b97647ba31a81eb Mon Sep 17 00:00:00 2001 From: Atridad Lahiji Date: Sun, 26 Jan 2025 14:40:30 -0600 Subject: [PATCH] Build --- .github/workflows/deploy.yml | 35 +++++++++++++++++++++++++++++++++++ Dockerfile | 18 ++++++++++++++++++ docker-compose.yml | 8 ++++++++ 3 files changed, 61 insertions(+) create mode 100644 .github/workflows/deploy.yml create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..abea909 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,35 @@ +name: Docker Deploy +on: + push: + branches: [main] + pull_request: + branches: [main] +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Container Registry + uses: docker/login-action@v2 + with: + registry: ${{ secrets.REPO_HOST }} + username: ${{ github.repository_owner }} + password: ${{ secrets.DEPLOY_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + platforms: linux/amd64 + push: true + tags: | + ${{ secrets.REPO_HOST }}/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }} + ${{ secrets.REPO_HOST }}/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ec018c9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM node:lts AS runtime +WORKDIR /app + +# Copy files +COPY . . + +# Install pnpm +RUN npm i -g pnpm + +# Install dependencies and build +RUN pnpm install +RUN pnpm run build + +ENV HOST=0.0.0.0 +ENV PORT=4321 +EXPOSE 4321 + +CMD ["node", "./dist/server/entry.mjs"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..438bdf1 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,8 @@ +services: + app: + image: ${IMAGE} + ports: + - "${APP_PORT}:4321" + environment: + NODE_ENV: production + restart: unless-stopped