From 9d4688e5ed2cd36f6b117b5ae5e821625e55cc44 Mon Sep 17 00:00:00 2001 From: Luke Bennett Date: Tue, 15 Jun 2021 11:02:47 +0100 Subject: [PATCH 1/3] ci: add Dockerfile and deploy workflow --- .github/workflows/deploy.yaml | 10 ++++++++++ Dockerfile | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 .github/workflows/deploy.yaml create mode 100644 Dockerfile diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..0c2e09f --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,10 @@ +name: Publish Staging +on: + push: + branches: + - main +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d7215c5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM debian:latest + +WORKDIR /ccash + +RUN apt update && apt -y install build-essential g++ cmake protobuf-compiler libjsoncpp-dev uuid-dev openssl libssl-dev zlib1g-dev + +COPY . . + +RUN mkdir build + +WORKDIR /ccash/build + +RUN cmake .. +RUN make -j$(nprov) + +CMD ["/ccash/build/bank", "AdminPassword", "10", "4"] From 7637446362d225a7f6d4ee8d2dd347472446735d Mon Sep 17 00:00:00 2001 From: Luke Bennett Date: Wed, 16 Jun 2021 01:10:49 +0100 Subject: [PATCH 2/3] chore: add .dockerignore --- .dockerignore | 1 + .gitignore | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +/build diff --git a/.gitignore b/.gitignore index 9d01538..928d28c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ .vscode build config.json -users.json \ No newline at end of file +users.json From 7152054edbb7bc4afad335c56723e4876e736d17 Mon Sep 17 00:00:00 2001 From: Luke Bennett Date: Wed, 16 Jun 2021 01:40:30 +0100 Subject: [PATCH 3/3] ci: CMD env vars, publish to GH packages --- .dockerignore | 1 + .github/workflows/deploy.yaml | 25 +++++++++++++++++++++++-- Dockerfile | 2 +- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/.dockerignore b/.dockerignore index 796b96d..c733f93 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,2 @@ /build +/config.json diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 0c2e09f..f0362e0 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -2,9 +2,30 @@ name: Publish Staging on: push: branches: - - main + - cicd jobs: release: + name: Push Docker image to GitHub Packages runs-on: ubuntu-latest + permissions: + packages: write + contents: read steps: - - uses: actions/checkout@v2 + - name: Checkout the repo + uses: actions/checkout@v2 + - name: Login to GitHub Docker Registry + uses: docker/login-action@v1 + with: + registry: docker.pkg.github.com + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Format repository + run: | + echo IMAGE_REPOSITORY=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV + - name: Build container image + uses: docker/build-push-action@v2 + with: + push: true + tags: | + docker.pkg.github.com/${{ env.IMAGE_REPOSITORY }}/ccash:${{ github.sha }} + docker.pkg.github.com/${{ env.IMAGE_REPOSITORY }}/ccash:latest diff --git a/Dockerfile b/Dockerfile index d7215c5..c14cd74 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,4 +13,4 @@ WORKDIR /ccash/build RUN cmake .. RUN make -j$(nprov) -CMD ["/ccash/build/bank", "AdminPassword", "10", "4"] +CMD ["/ccash/build/bank", "$CCASH_ADMIN_PASSWORD", "$CCASH_SAVE_FREQUENCY", "$CCASH_THREAD_COUNT"]