From f9bad576ce4272b4f29b968b9b60b3fabbffa06b Mon Sep 17 00:00:00 2001 From: Nex Sabre Date: Sat, 19 Nov 2022 00:21:25 +0100 Subject: [PATCH] fix: Fix CI issue with docker (#94) --- .github/workflows/ci.yml | 106 +++++++++++++++++++++------------------ Dockerfile | 6 +-- 2 files changed, 60 insertions(+), 52 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1bc0538..80b4ce5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,8 +9,8 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-python@v4 with: - python-version: '3.11' - cache: 'pip' + python-version: "3.11" + cache: "pip" - name: Install Python dependencies (pip) run: | pip install -r requirements-dev.txt @@ -48,6 +48,14 @@ jobs: - name: Verify imports (w/isort) run: | isort --check ph/ tests/ --profile black + verify-docker: + name: Build a docker image + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Docker build + run: | + docker build -t ph . release: name: Prepare release if: ${{ github.ref == 'refs/heads/main' }} @@ -91,56 +99,56 @@ jobs: env: HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} run: heroku container:release web -a packet-helper -# push_to_registry_pr: -# name: Push Docker image to HerokuApp (as development env) -# if: ${{ github.ref != 'refs/heads/main' }} -# needs: [verify-django, verify-js, verify-python] -# runs-on: ubuntu-latest -# environment: -# name: development -# url: https://packet-helper-pr.herokuapp.com/ -# steps: -# - name: Checkout repository -# uses: actions/checkout@v2 -# with: -# fetch-depth: 0 -# - name: Add SHORT_SHA env property with commit short sha -# run: | -# echo "GIT_VERSION_TAG=`git describe --tags --abbrev=0`" >> $GITHUB_ENV -# echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV -# - name: Login to Heroku Container registry -# env: -# HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} -# run: heroku container:login -# - name: Build and push -# env: -# HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} -# run: | -# heroku container:push web -a packet-helper-pr --arg PH_VER="${GIT_VERSION_TAG}:${SHORT_SHA}" -# - name: Release -# env: -# HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} -# run: heroku container:release web -a packet-helper-pr -# post_deploy_check_pr: -# name: Check status of env (as development env) -# if: ${{ github.ref != 'refs/heads/main' }} -# needs: [ push_to_registry_pr ] -# runs-on: ubuntu-latest -# steps: -# - name: Checkout repository -# uses: actions/checkout@v2 -# with: -# fetch-depth: 0 -# - name: Verify /api/info -# run: | -# pip install requests pydantic -# export GIT_VERSION_TAG=`git describe --tags --abbrev=0` -# export SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8` -# python check_deployment.py https://packet-helper-pr.herokuapp.com $GIT_VERSION_TAG $SHORT_SHA + # push_to_registry_pr: + # name: Push Docker image to HerokuApp (as development env) + # if: ${{ github.ref != 'refs/heads/main' }} + # needs: [verify-django, verify-js, verify-python] + # runs-on: ubuntu-latest + # environment: + # name: development + # url: https://packet-helper-pr.herokuapp.com/ + # steps: + # - name: Checkout repository + # uses: actions/checkout@v2 + # with: + # fetch-depth: 0 + # - name: Add SHORT_SHA env property with commit short sha + # run: | + # echo "GIT_VERSION_TAG=`git describe --tags --abbrev=0`" >> $GITHUB_ENV + # echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV + # - name: Login to Heroku Container registry + # env: + # HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} + # run: heroku container:login + # - name: Build and push + # env: + # HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} + # run: | + # heroku container:push web -a packet-helper-pr --arg PH_VER="${GIT_VERSION_TAG}:${SHORT_SHA}" + # - name: Release + # env: + # HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} + # run: heroku container:release web -a packet-helper-pr + # post_deploy_check_pr: + # name: Check status of env (as development env) + # if: ${{ github.ref != 'refs/heads/main' }} + # needs: [ push_to_registry_pr ] + # runs-on: ubuntu-latest + # steps: + # - name: Checkout repository + # uses: actions/checkout@v2 + # with: + # fetch-depth: 0 + # - name: Verify /api/info + # run: | + # pip install requests pydantic + # export GIT_VERSION_TAG=`git describe --tags --abbrev=0` + # export SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8` + # python check_deployment.py https://packet-helper-pr.herokuapp.com $GIT_VERSION_TAG $SHORT_SHA post_deploy_check_prod: name: Check status of env (as production env) if: ${{ github.ref != 'refs/heads/main' }} - needs: [ push_to_registry ] + needs: [push_to_registry] runs-on: ubuntu-latest steps: - name: Checkout repository diff --git a/Dockerfile b/Dockerfile index c2e3043..7655d96 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,14 @@ # build stage (frontend) -FROM node:lts-alpine as build-stage +FROM node:lts-alpine@sha256:2175727cef5cad4020cb77c8c101d56ed41d44fbe9b1157c54f820e3d345eab1 as build-stage WORKDIR /app -COPY package*.json ./ +COPY package.json yarn.lock ./ RUN yarn -g install COPY . . RUN yarn build # build stage (backend & package) -FROM python:3.11-buster +FROM python:3.11-buster@sha256:43db725cf6c954611ffe4938e330e8d18b48627ad19e4f1ed62196baf5a3ca58 # Install tshark/wireshark dependecies RUN echo "wireshark-common wireshark-common/install-setuid boolean true" | debconf-set-selections