mirror of
https://github.com/sp-tarkov/db-website.git
synced 2025-02-08 05:10:46 -05:00
Creates Dockerfile & Build and Publish Workflow
This commit is contained in:
parent
16ae57037e
commit
824e5c3742
69
.github/workflows/build.yaml
vendored
Normal file
69
.github/workflows/build.yaml
vendored
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
name: Build and Publish Docker Image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: ['main']
|
||||||
|
|
||||||
|
# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and
|
||||||
|
# a name for the Docker image that this workflow builds.
|
||||||
|
env:
|
||||||
|
REGISTRY: ghcr.io
|
||||||
|
IMAGE_NAME: ${{ github.repository }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push-image:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
attestations: write
|
||||||
|
id-token: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and
|
||||||
|
# password that will publish the packages. Once published, the packages are scoped to the account defined here.
|
||||||
|
- name: Log in to the Container registry
|
||||||
|
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ secrets.USERNAME }}
|
||||||
|
password: ${{ secrets.TOKEN }}
|
||||||
|
|
||||||
|
# This step uses https://github.com/docker/metadata-action#about to extract tags and labels that will be applied
|
||||||
|
# to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step.
|
||||||
|
# The `images` value provides the base name for the tags and labels.
|
||||||
|
- name: Extract metadata (tags, labels) for Docker
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
|
||||||
|
with:
|
||||||
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
|
|
||||||
|
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`.
|
||||||
|
# If the build succeeds, it pushes the image to GitHub Packages. It uses the `context` parameter to define the
|
||||||
|
# build's context as the set of files located in the specified path. For more information, see
|
||||||
|
# https://github.com/docker/build-push-action#usage in the README of the `docker/build-push-action` repository.
|
||||||
|
# It uses the `tags` and `labels` parameters to tag and label the image with the output of the "meta" step.
|
||||||
|
- name: Build and push Docker image
|
||||||
|
id: push
|
||||||
|
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|
||||||
|
# This step generates an artifact attestation for the image, which is an unforgeable statement about where and
|
||||||
|
# how it was built. It increases supply chain security for people who consume the image. For more information,
|
||||||
|
# see: /actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds
|
||||||
|
- name: Generate artifact attestation
|
||||||
|
uses: actions/attest-build-provenance@v1
|
||||||
|
with:
|
||||||
|
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
|
||||||
|
subject-digest: ${{ steps.push.outputs.digest }}
|
||||||
|
push-to-registry: true
|
||||||
|
|
34
Dockerfile
Normal file
34
Dockerfile
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
FROM node:20.12-slim AS base
|
||||||
|
|
||||||
|
# Update and install dependencies
|
||||||
|
RUN apt-get update && apt-get install -y curl unzip && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Install Latest Bun
|
||||||
|
RUN curl -fsSL https://bun.sh/install | bash
|
||||||
|
ENV BUN_INSTALL="/root/.bun"
|
||||||
|
ENV PATH="$BUN_INSTALL/bin:$PATH"
|
||||||
|
|
||||||
|
# Frontend build stage
|
||||||
|
FROM base AS frontend-build
|
||||||
|
WORKDIR /app/frontend
|
||||||
|
COPY frontend .
|
||||||
|
RUN npm install
|
||||||
|
RUN npm run build:prod
|
||||||
|
|
||||||
|
# Copy built frontend into backend public directory
|
||||||
|
FROM base AS backend-build
|
||||||
|
WORKDIR /app/api
|
||||||
|
RUN mkdir -p /app/api/public
|
||||||
|
COPY --from=frontend-build /app/frontend/dist/* /app/api/public/
|
||||||
|
|
||||||
|
# Backend build stage
|
||||||
|
COPY api .
|
||||||
|
RUN cp .env.example .env
|
||||||
|
RUN bun install
|
||||||
|
|
||||||
|
# Final image
|
||||||
|
FROM base
|
||||||
|
WORKDIR /app/api
|
||||||
|
COPY --from=backend-build /app/api .
|
||||||
|
EXPOSE 3001
|
||||||
|
CMD ["bun", "run", "start"]
|
Loading…
x
Reference in New Issue
Block a user