From 049cb9b6b3e7bd3dd0fa342c0de7de40a530ed66 Mon Sep 17 00:00:00 2001 From: j4qfrost Date: Sun, 29 Sep 2024 02:33:24 -0700 Subject: [PATCH] Feature/ci container build publish (#349) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add test for HandleHTTPError undelete * more verbose http codes * Update Dockerfile Now using go 1.23! Tested this on dev, it works * Update compose_dev.sh Prints initial settings as defined in setup.yaml. Added for usability reasons - users keep getting confused about account balance and maximum allowable debt * add failure condition test * formatting and test standards * add frontend file polling for wsl2 * Add test for HandleHTTPError (#278) * add test for HandleHTTPError undelete * more verbose http codes * Update Dockerfile Now using go 1.23! Tested this on dev, it works * Update compose_dev.sh Prints initial settings as defined in setup.yaml. Added for usability reasons - users keep getting confused about account balance and maximum allowable debt * add failure condition test * formatting and test standards --------- Co-authored-by: Osnat Katz Moon <137817983+astrosnat@users.noreply.github.com> * add failure condition test (#282) * Creation of Market Price Projection API (#277) * Moving test to appropriate location. * Updating, including moving test location. Test not passing due to precision error but generally passing on the terminal up to 6 dits. * market projection handler, not working. * Update market projected probability. * Safe uint conversion. * Updating, adding noop change to push into pipeline. * Update, test passing. * Update, attempting to solve type converstion uint problem. * Adding projected market layout. * Update, still have react JSON parse error but layout added to buyshares. * Market projection updates on buy shares side, upon button press. * Update, change printf to print. * Create SECURITY.md * Adding Fees to Buying and Selling Bets (#287) * Drafting out fees deduction functions and capability. * Attempting working version of initialBetFee function. * Draft adding fees. * Update, adding tests. * Adding working test for GetBetsForMarket * Successful fee util test. * Fees added on backend, tests passing. * Updating such that user record submitted. However fee summing not working yet evidently. * Working fees, at least initial fees. * Updating test scenario passing, made more clear. * Update Dockerfile We need to switch to 3.0.14-1~deb12u2 * Removing logging. * Adding fees, including communicating fees on front end. * totalBetCount to userBetCount so as not to misconstrue meaning. * Simplifying function, test passed. * Simplifying naming. * Updating new function name in test * Changing test to got before want convention. * Update marketid variable * Add combined fee structure for more througough test. * Reverting sale amount to 1 share. * Reversing got want --------- Co-authored-by: Osnat Katz Moon <137817983+astrosnat@users.noreply.github.com> * Frontend fixes (#286) * fix: fixed the market buttons not showing on mobile * fix: removed trade button on closed market --------- Co-authored-by: Patrick Delaney * Attempting toa ddress cors related security concern. (#298) * Drafting out reporting stats. * Add support for dependency injection to setup (#301) * Make EconomicsConfig from component structs Auto initialize config Add support to inject config Add support for testing the setup through test doubles Use new fee for placing bets (EachBetFee) * revert * Fix/remove wsl check (#337) * add failure condition test * Add test for HandleHTTPError (#278) * add test for HandleHTTPError undelete * more verbose http codes * Update Dockerfile Now using go 1.23! Tested this on dev, it works * Update compose_dev.sh Prints initial settings as defined in setup.yaml. Added for usability reasons - users keep getting confused about account balance and maximum allowable debt * add failure condition test * formatting and test standards --------- Co-authored-by: Osnat Katz Moon <137817983+astrosnat@users.noreply.github.com> * add failure condition test (#282) * Creation of Market Price Projection API (#277) * Moving test to appropriate location. * Updating, including moving test location. Test not passing due to precision error but generally passing on the terminal up to 6 dits. * market projection handler, not working. * Update market projected probability. * Safe uint conversion. * Updating, adding noop change to push into pipeline. * Update, test passing. * Update, attempting to solve type converstion uint problem. * Adding projected market layout. * Update, still have react JSON parse error but layout added to buyshares. * Market projection updates on buy shares side, upon button press. * Update, change printf to print. * Create SECURITY.md * Adding Fees to Buying and Selling Bets (#287) * Drafting out fees deduction functions and capability. * Attempting working version of initialBetFee function. * Draft adding fees. * Update, adding tests. * Adding working test for GetBetsForMarket * Successful fee util test. * Fees added on backend, tests passing. * Updating such that user record submitted. However fee summing not working yet evidently. * Working fees, at least initial fees. * Updating test scenario passing, made more clear. * Update Dockerfile We need to switch to 3.0.14-1~deb12u2 * Removing logging. * Adding fees, including communicating fees on front end. * totalBetCount to userBetCount so as not to misconstrue meaning. * Simplifying function, test passed. * Simplifying naming. * Updating new function name in test * Changing test to got before want convention. * Update marketid variable * Add combined fee structure for more througough test. * Reverting sale amount to 1 share. * Reversing got want --------- Co-authored-by: Osnat Katz Moon <137817983+astrosnat@users.noreply.github.com> * Frontend fixes (#286) * fix: fixed the market buttons not showing on mobile * fix: removed trade button on closed market --------- Co-authored-by: Patrick Delaney * Attempting toa ddress cors related security concern. (#298) * Drafting out reporting stats. * Add support for dependency injection to setup (#301) * Make EconomicsConfig from component structs Auto initialize config Add support to inject config Add support for testing the setup through test doubles Use new fee for placing bets (EachBetFee) * remove wsl check * remove watcher --------- Co-authored-by: Osnat Katz Moon <137817983+astrosnat@users.noreply.github.com> Co-authored-by: Patrick Delaney Co-authored-by: Marko Kovač <124689071+markokovac16@users.noreply.github.com> Co-authored-by: Arthur <25300182+ajlacey@users.noreply.github.com> * Feature/frontend vite build (#341) * add test for HandleHTTPError undelete * more verbose http codes * Update Dockerfile Now using go 1.23! Tested this on dev, it works * Update compose_dev.sh Prints initial settings as defined in setup.yaml. Added for usability reasons - users keep getting confused about account balance and maximum allowable debt * add failure condition test * formatting and test standards * add frontend file polling for wsl2 * Add test for HandleHTTPError (#278) * add test for HandleHTTPError undelete * more verbose http codes * Update Dockerfile Now using go 1.23! Tested this on dev, it works * Update compose_dev.sh Prints initial settings as defined in setup.yaml. Added for usability reasons - users keep getting confused about account balance and maximum allowable debt * add failure condition test * formatting and test standards --------- Co-authored-by: Osnat Katz Moon <137817983+astrosnat@users.noreply.github.com> * add failure condition test (#282) * Creation of Market Price Projection API (#277) * Moving test to appropriate location. * Updating, including moving test location. Test not passing due to precision error but generally passing on the terminal up to 6 dits. * market projection handler, not working. * Update market projected probability. * Safe uint conversion. * Updating, adding noop change to push into pipeline. * Update, test passing. * Update, attempting to solve type converstion uint problem. * Adding projected market layout. * Update, still have react JSON parse error but layout added to buyshares. * Market projection updates on buy shares side, upon button press. * Update, change printf to print. * Create SECURITY.md * Adding Fees to Buying and Selling Bets (#287) * Drafting out fees deduction functions and capability. * Attempting working version of initialBetFee function. * Draft adding fees. * Update, adding tests. * Adding working test for GetBetsForMarket * Successful fee util test. * Fees added on backend, tests passing. * Updating such that user record submitted. However fee summing not working yet evidently. * Working fees, at least initial fees. * Updating test scenario passing, made more clear. * Update Dockerfile We need to switch to 3.0.14-1~deb12u2 * Removing logging. * Adding fees, including communicating fees on front end. * totalBetCount to userBetCount so as not to misconstrue meaning. * Simplifying function, test passed. * Simplifying naming. * Updating new function name in test * Changing test to got before want convention. * Update marketid variable * Add combined fee structure for more througough test. * Reverting sale amount to 1 share. * Reversing got want --------- Co-authored-by: Osnat Katz Moon <137817983+astrosnat@users.noreply.github.com> * Frontend fixes (#286) * fix: fixed the market buttons not showing on mobile * fix: removed trade button on closed market --------- Co-authored-by: Patrick Delaney * Attempting toa ddress cors related security concern. (#298) * Drafting out reporting stats. * Add support for dependency injection to setup (#301) * Make EconomicsConfig from component structs Auto initialize config Add support to inject config Add support for testing the setup through test doubles Use new fee for placing bets (EachBetFee) * revert * feat(frontend): Compiles frontend into single js file for performance * forgot merge --------- Co-authored-by: Osnat Katz Moon <137817983+astrosnat@users.noreply.github.com> Co-authored-by: Patrick Delaney Co-authored-by: Marko Kovač <124689071+markokovac16@users.noreply.github.com> Co-authored-by: Arthur <25300182+ajlacey@users.noreply.github.com> * feat(ci): Add docker creation workflow * separate builds * on branch up * main * correct files * remove syntax check * fix metas * meta access * attestation * separate attestations * latest tag * tag change * caching * buildx and tagging * retag and test cache * tagging * automate on tags * added back for security --------- Co-authored-by: Osnat Katz Moon <137817983+astrosnat@users.noreply.github.com> Co-authored-by: Patrick Delaney Co-authored-by: Marko Kovač <124689071+markokovac16@users.noreply.github.com> Co-authored-by: Arthur <25300182+ajlacey@users.noreply.github.com> --- .github/workflows/docker.yml | 88 ++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 00000000..bf3cbcca --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,88 @@ +name: Create and publish a Docker image + +on: + push: + branches: + - main + tags: + - 'v*' + +concurrency: + group: "publish" + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + attestations: write + id-token: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.DOCKER_TOKEN }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Extract metadata (tags, labels) for Frontend + id: frontend-meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-frontend + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + + - name: Build and push Frontend + id: frontend + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: ./frontend + file: ./frontend/Dockerfile.prod + cache-from: type=gha + cache-to: type=gha,mode=max + github-token: ${{ secrets.DOCKER_TOKEN }} + push: true + tags: ${{ steps.frontend-meta.outputs.tags }},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-frontend:latest + labels: ${{ steps.frontend-meta.outputs.labels }} + - name: Generate artifact attestation Frontend + uses: actions/attest-build-provenance@v1 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}-frontend + subject-digest: ${{ steps.frontend.outputs.digest }} + push-to-registry: true + + - name: Extract metadata (tags, labels) for Backend + id: backend-meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-backend + - name: Build and push Backend + id: backend + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: ./backend + file: ./backend/Dockerfile + cache-from: type=gha + cache-to: type=gha,mode=max + github-token: ${{ secrets.DOCKER_TOKEN }} + push: true + tags: ${{ steps.backend-meta.outputs.tags }},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-backend:latest + labels: ${{ steps.backend-meta.outputs.labels }} + - name: Generate artifact attestation Backend + uses: actions/attest-build-provenance@v1 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}-backend + subject-digest: ${{ steps.backend.outputs.digest }} + push-to-registry: true \ No newline at end of file