diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..d204014 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +node_modules +dist +.git +.env +.vscode \ No newline at end of file diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml deleted file mode 100644 index 1b6ba8f..0000000 --- a/.forgejo/workflows/build.yaml +++ /dev/null @@ -1,16 +0,0 @@ -on: - workflow_dispatch: - push: - -jobs: - build: - runs-on: docker - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 'latest' - check-latest: true - cache: 'yarn' - - run: | - yarn build diff --git a/.github/workflows/build-docker.yaml b/.github/workflows/build-docker.yaml new file mode 100644 index 0000000..57eee1f --- /dev/null +++ b/.github/workflows/build-docker.yaml @@ -0,0 +1,38 @@ +name: Build and Push Docker + +on: + workflow_dispatch: + push: + branches: + - dev + - prod + +env: + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} + +jobs: + build-and-push: + runs-on: ubuntu-latest + + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + #- name: Set up Tailscale + # uses: tailscale/github-action@v2 + # with: + # authkey: ${{ secrets.TAILSCALE_AUTHKEY }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ secrets.DOCKERHUB_USERNAME }}/soc-site:${{ BRANCH_NAME }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..993fa82 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM node:24-alpine AS builder +WORKDIR /app +COPY . . +RUN yarn install --frozen-lockfile +RUN yarn build + +FROM node:24-alpine AS dependencies +WORKDIR /app +COPY package.json yarn.lock ./ +RUN yarn install --production --frozen-lockfile + +FROM node:24-alpine AS runner +WORKDIR /app +ENV HOST=0.0.0.0 +ENV PORT=80 +EXPOSE 80 +COPY --from=builder /app/dist ./dist +COPY --from=dependencies /app/node_modules ./node_modules +CMD ["node", "./dist/server/entry.mjs"] \ No newline at end of file