diff --git a/.changeset/config.json b/.changeset/config.json index dbf3a08d2..f0cd9e19a 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -7,14 +7,10 @@ } ], "commit": false, - "fixed": [ - [ - "@lagon/runtime", - "@lagon/js-runtime" - ] - ], + "fixed": [["@lagon/runtime", "@lagon/js-runtime"]], "linked": [], "access": "public", "baseBranch": "main", - "updateInternalDependencies": "patch" -} \ No newline at end of file + "updateInternalDependencies": "patch", + "privatePackages": { "version": true, "tag": true } +} diff --git a/.changeset/flat-rabbits-shake.md b/.changeset/flat-rabbits-shake.md new file mode 100644 index 000000000..1665e1b35 --- /dev/null +++ b/.changeset/flat-rabbits-shake.md @@ -0,0 +1,5 @@ +--- +'@lagon/serverless': minor +--- + +Release container image diff --git a/.dockerignore b/.dockerignore index 690efcc23..a23ba8822 100644 --- a/.dockerignore +++ b/.dockerignore @@ -8,3 +8,4 @@ dist/ .env .eslintcache crates/serverless/deployments/ +docker/ diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml new file mode 100644 index 000000000..1f65bb5b4 --- /dev/null +++ b/.github/workflows/container.yml @@ -0,0 +1,70 @@ +name: Container + +on: + push: + branches: + - main + tags: + - '@lagon/serverless@*' + pull_request: + +env: + DOCKER_HUB_USER: lagonapp + +jobs: + create-container-image: + name: Create "${{matrix.image}}" container image + runs-on: ubuntu-latest + strategy: + matrix: + # image: [serverless, dashboard] + image: [serverless] + steps: + - name: Checkout 🛎️ + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: | + ${{ env.DOCKER_HUB_USER }}/${{matrix.image}} + ghcr.io/${{ github.repository_owner }}/${{matrix.image}} + tags: | + type=ref,event=tag,prefix=@lagon/${{matrix.image}}@ + type=ref,event=pr + type=raw,value=next,enable={{is_default_branch}} + + - name: Login to ghcr.io registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Login to Docker Hub + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + username: ${{ env.DOCKER_HUB_USER }} + password: ${{ secrets.DOCKER_HUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v4 + if: "!startsWith(github.ref, 'refs/tags/') || contains(github.ref, matrix.image)" # only execute if not tag or tag with specific matrix image + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + file: docker/Dockerfile.${{matrix.image}} + platforms: ${{ github.event_name == 'pull_request' && 'linux/amd64' || 'linux/amd64,linux/arm64' }} # only build for amd64 on PRs to speed up CI job diff --git a/docker/Dockerfile b/docker/Dockerfile.serverless similarity index 91% rename from docker/Dockerfile rename to docker/Dockerfile.serverless index 11131de8c..c5a3b60c9 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile.serverless @@ -17,7 +17,7 @@ FROM chef AS builder COPY --from=planner /app/recipe.json recipe.json RUN cargo chef cook --release --recipe-path recipe.json COPY . . -COPY --from=js-runtime /app/dist/index.js /app/crates/js-runtime/dist +COPY --from=js-runtime /app/dist/index.js /app/crates/runtime_isolate/runtime.js RUN cargo build --release --bin lagon-serverless FROM debian:bullseye-slim AS runtime diff --git a/package.json b/package.json index a027b7266..de52904d9 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "build": "turbo build --continue --filter=!@lagon/example-*", "lint": "turbo lint --continue", "typecheck": "turbo typecheck --continue", - "docker:build": "docker build -t lagon/serverless -f docker/Dockerfile .", + "docker:build": "docker build -t lagon/serverless -f docker/Dockerfile.serverless .", "docker:start": "docker run --rm -p 4000:4000 --env-file crates/serverless/.env lagon/serverless", "release": "pnpm build --filter=@lagon/astro --filter=@lagon/remix && pnpm changeset publish" },