From e8b80b21e739b20c1f6aed0b19e56ae8113bcf8e Mon Sep 17 00:00:00 2001 From: lAmeR1 Date: Tue, 7 May 2024 08:09:25 +0200 Subject: [PATCH] Add docker files --- .github/workflows/docker-testimage.yml | 57 ++++++++++++++++---------- Dockerfile | 24 +++++++++++ 2 files changed, 60 insertions(+), 21 deletions(-) create mode 100644 Dockerfile diff --git a/.github/workflows/docker-testimage.yml b/.github/workflows/docker-testimage.yml index 11440aa..ba39f34 100644 --- a/.github/workflows/docker-testimage.yml +++ b/.github/workflows/docker-testimage.yml @@ -1,25 +1,40 @@ -name: Docker Image TESTBUILD - -on: - workflow_dispatch +name: Docker Image +on: push jobs: build: - runs-on: ubuntu-latest + strategy: + matrix: + os: [ubuntu-latest] + arch: [amd64, arm64] + + runs-on: ${{ matrix.os }} + steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: lamer1 - password: ${{ secrets.DOCKER_ACCESS_TOKEN }} - - name: Build and push - uses: docker/build-push-action@v4 - with: - context: . - push: true - tags: supertypo/kaspa-rest-server:test - file: ./docker/Dockerfile - build-args: | - version=${{github.ref_name}} + - name: Add SHORT_SHA env property with commit short sha + run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV + - name: Checkout code + uses: actions/checkout@v2 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: lamer1 + password: ${{ secrets.DOCKER_ACCESS_TOKEN }} + + - name: Set up QEMU (for ARM64 emulation) + if: matrix.arch == 'arm64' + run: | + sudo apt-get install -y qemu-user-static + + - name: Set up Docker Buildx (for multi-platform builds) + uses: docker/setup-buildx-action@v1 + + - name: Build and push Docker image + run: | + docker buildx build \ + --platform linux/amd64,linux/arm64 \ + -t supertypo/kaspa-rest-server:${SHORT_SHA} \ + --push . + + docker buildx imagetools inspect supertypo/kaspa-rest-server:${SHORT_SHA} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..eb1affe --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM python:3.12-slim + +ARG REPO_DIR + +EXPOSE 8000 + +ENV KASPAD_HOST_1=n.seeder1.kaspad.net:16110 +ARG version +ENV VERSION=$version + +RUN apt update +RUN apt install uvicorn gunicorn -y + +WORKDIR /app +COPY . . + +RUN python -m pip install --upgrade pip +RUN pip install poetry +RUN poetry install --no-root --no-interaction + +# make pipenv commands still running +RUN ln /usr/local/bin/poetry /usr/local/bin/pipenv + +CMD poetry run gunicorn -b 0.0.0.0:8000 -w 4 -k uvicorn.workers.UvicornWorker main:app --timeout 120 \ No newline at end of file