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..4f0c70d --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,55 @@ +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: 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 }} + cache-from: type=gha + cache-to: type=gha,mode=max 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" ]