From 0a5da7960ddd38986b0f0014d10fa132cb471c23 Mon Sep 17 00:00:00 2001 From: James Smith Date: Wed, 16 Oct 2024 22:30:34 +0100 Subject: [PATCH] add docker build --- .github/workflows/docker.yml | 46 ++++++++++++++++++++++++++++++++++++ .ruby-version | 2 +- Dockerfile | 11 +++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/docker.yml create mode 100644 Dockerfile diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..d08f398 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,46 @@ +name: Docker + +on: + push: + branches: [ "main" ] + workflow_dispatch: + inputs: + tag: + description: 'Docker tag for build results' + type: string + default: manual + required: true + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read # for checkout + id-token: write # for OIDC token, used for Depot + packages: write # to upload build to GHCR + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Work out Docker tags + id: docker_meta + uses: docker/metadata-action@v5 + with: + tags: | + type=raw,value=${{ inputs.tag }},event=workflow_dispatch + type=edge + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + id: docker + uses: docker/build-push-action@v1 + with: + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.docker_meta.outputs.tags }} + labels: ${{ steps.docker_meta.outputs.labels }} diff --git a/.ruby-version b/.ruby-version index 15a2799..fa7adc7 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.3.0 +3.3.5 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8945c31 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM ruby:3.3 + +RUN mkdir -p /usr/src/app +WORKDIR /usr/src/app + +COPY . /usr/src/app +RUN bundle install + +EXPOSE 9292 + +CMD [ "rackup", "-o", "0.0.0.0" ]