diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +node_modules diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index faddb6e..16324e7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -11,7 +11,7 @@ jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: install run: yarn install - name: format diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml new file mode 100644 index 0000000..7f416bb --- /dev/null +++ b/.github/workflows/docker.yaml @@ -0,0 +1,47 @@ +name: Create and publish Docker image + +on: + # release: + # types: [published] + push: + branches: + - main + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +# https://docs.docker.com/build/ci/github-actions/multi-platform/ + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 57d6a14..36c500d 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -18,3 +18,4 @@ jobs: - run: yarn npm publish // for Yarn version 1, use `yarn publish` instead env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2454212 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,39 @@ +# syntax=docker/dockerfile:1.4 +FROM node:lts-slim AS development + +LABEL org.opencontainers.image.source=https://github.com/automerge/automerge-repo-sync-server +LABEL org.opencontainers.image.description="A debugging/test instance of automerge-repo-sync-server" +LABEL org.opencontainers.image.licenses=MIT + +# Create app directory +WORKDIR /usr/src/app + +COPY package.json ./package.json +RUN yarn install + +COPY . . + +EXPOSE 3030 +# NODE_ENV=dev DEBUG=* node ./src/index.js +ENV NODE_ENV=dev +ENV DEBUG=* +CMD [ "node", "./src/index.js" ] + +FROM development as dev-envs +RUN <