From f4b2adfedc074f65d6ffa3a5adb28a3b74174ccb Mon Sep 17 00:00:00 2001 From: FedotCompot Date: Thu, 27 Feb 2025 01:00:53 +0100 Subject: [PATCH 1/2] Added build automation and Dockerfile --- .dockerignore | 3 +++ .github/workflows/main.yaml | 44 +++++++++++++++++++++++++++++++++++++ Dockerfile | 42 +++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/main.yaml create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..68993d6 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +.github/ +.git/ +README.md \ No newline at end of file diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 0000000..3e01d15 --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,44 @@ + +on: + push: + branches: + - main + tags: + - v* + + +jobs: + build: + name: Build & Push Docker Image + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=raw,value=latest,enable={{is_default_branch}} + type=semver,pattern={{raw}} + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha,format=long,prefix= + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0d508d7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +FROM ubuntu:latest AS build + + +RUN apt update && apt install cmake git clang zlib1g zlib1g-dev libllvm18 llvm llvm-dev llvm-runtime liblld-dev liblld-18 libpolly-18-dev -y + +RUN git clone https://github.com/c3lang/c3c && \ + cd c3c && \ + git checkout 855be9288121d0f7a67d277f7bbbbf57fbfa2597 && \ + mkdir build && \ + cd build && \ + cmake .. && \ + cmake --build . && \ + chmod +x c3c && \ + cp c3c /usr/local/bin/c3c && \ + cp -r lib /usr/local/bin/lib + + + +RUN apt install nodejs npm -y + +WORKDIR /app + +COPY package.json package.json +COPY package-lock.json package-lock.json +RUN npm install + + +COPY . . +RUN npm run build + +FROM node:latest AS run + +WORKDIR /app + +COPY --from=build /lib/x86_64-linux-gnu /lib/x86_64-linux-gnu +COPY --from=build /app . + +RUN npm i + +COPY --from=build /app/build/server build/server + +ENTRYPOINT [ "npm", "run", "serve" ] From b6c870a342a2f32ce3fa51c88b343f28a65f9ec7 Mon Sep 17 00:00:00 2001 From: FedotCompot Date: Tue, 10 Jun 2025 13:18:42 +0200 Subject: [PATCH 2/2] feat(workflow): caches --- .github/workflows/main.yaml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 3e01d15..4f0c70d 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -1,12 +1,10 @@ - on: push: branches: - - main + - main tags: - v* - jobs: build: name: Build & Push Docker Image @@ -35,10 +33,23 @@ jobs: type=semver,pattern={{major}} type=sha,format=long,prefix= + - name: Set up Docker + uses: docker/setup-docker-action@v4 + with: + version: latest + daemon-config: | + { + "features": { + "containerd-snapshotter": true + } + } + - name: Build and push Docker image uses: docker/build-push-action@v6 with: context: . push: true tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max