From e0560d12e98e32a1d6611e66f5ead3a555132da9 Mon Sep 17 00:00:00 2001 From: PeterNashaat Date: Wed, 22 May 2024 07:18:57 +0000 Subject: [PATCH 1/8] adding staging tfconnect-news workflow on prod2 ns threefoldconnect-staging --- .github/workflows/staging.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/staging.yml diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml new file mode 100644 index 0000000..94e3dfb --- /dev/null +++ b/.github/workflows/staging.yml @@ -0,0 +1,35 @@ +name: News Staging + +on: + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Log into Docker Hub Registry + uses: docker/login-action@v2 + with: + username: ${{ secrets.TFDOCKERHUB_USERNAME }} + password: ${{ secrets.TFDOCKERHUB_PASSWORD }} + + - name: Build the Docker image + run: docker build . -t threefolddev/staging-threefold-connect-news:${{ github.sha }} + + - name: Push to dockerhub + run: docker push threefolddev/staing-threefold-connect-news:${{ github.sha }} + + deploy: + needs: [build] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Create kubeconfig + run: | + mkdir ${HOME}/.kube + echo ${{ secrets.TF_KUBE_CONFIG }} | base64 --decode > ${HOME}/.kube/config + - name: deploy or upgrade new to kubernetes threefoldconnect-staging + run: helm upgrade news helm_files --set image.tag=${{ github.sha }} -n threefoldconnect-staging From bfce821f00152991a2da62cfb1e28afcab9b0efb Mon Sep 17 00:00:00 2001 From: PeterNashaat Date: Wed, 22 May 2024 08:27:38 +0000 Subject: [PATCH 2/8] fixing docker build in dockerfile yarn install issue --- Dockerfile | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9777b86..61103b8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,38 +1,39 @@ -FROM ubuntu:latest as builder -RUN apt-get update - -# Is optional, but if you are not going to use this then you will need to install -# 'gnupg' for nodesource so it can setup node install -RUN apt-get install -y build-essential python-is-python3 make gcc g++ - -RUN apt-get -y install curl - -# The next 2 steps will install node -#RUN curl -sL https://deb.nodesource.com/setup_15.x | bash - - -RUN curl -LO https://nodejs.org/dist/v18.0.0/node-v18.0.0-linux-x64.tar.xz sudo tar -xvf node-v18.0.0-linux-x64.tar.xz sudo cp -r node-v18.0.0-linux-x64/{bin,include,lib,share} /usr/ node --version => v18.0.0 - -# The next 3 steps are for installing yarn -RUN curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - - - -RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list - -RUN apt-get update && apt-get install yarn -y - +FROM python:2.7 as builder + +# Update and install dependencies +RUN apt-get update && \ + apt-get install -y build-essential make gcc g++ curl gnupg + +# Install Node.js +RUN curl -LO https://nodejs.org/dist/v18.0.0/node-v18.0.0-linux-x64.tar.xz && \ + tar -xvf node-v18.0.0-linux-x64.tar.xz && \ + cp -r node-v18.0.0-linux-x64/bin/* /usr/bin/ && \ + cp -r node-v18.0.0-linux-x64/include/* /usr/include/ && \ + cp -r node-v18.0.0-linux-x64/lib/* /usr/lib/ && \ + cp -r node-v18.0.0-linux-x64/share/* /usr/share/ && \ + node --version + +# Install Yarn +RUN curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \ + echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list && \ + apt-get update && apt-get install -y yarn WORKDIR /app +# Show Node.js version RUN node --version -COPY package.json package.json -COPY yarn.lock yarn.lock - +# Copy and install dependencies +COPY package.json yarn.lock ./ RUN yarn install + +# Copy the rest of the application code COPY . . +# Build the application RUN yarn build +# Use Nginx as the server FROM nginx:alpine as server COPY --from=builder /app/dist /usr/share/nginx/html CMD ["nginx", "-g", "daemon off;"] From 80d317b5a9b6a7e4e4cf3419f19c2bfccd10093b Mon Sep 17 00:00:00 2001 From: PeterNashaat Date: Wed, 22 May 2024 08:36:58 +0000 Subject: [PATCH 3/8] workflow typo image name --- .github/workflows/staging.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index 94e3dfb..a001845 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -20,7 +20,7 @@ jobs: run: docker build . -t threefolddev/staging-threefold-connect-news:${{ github.sha }} - name: Push to dockerhub - run: docker push threefolddev/staing-threefold-connect-news:${{ github.sha }} + run: docker push threefolddev/staging-threefold-connect-news:${{ github.sha }} deploy: needs: [build] From b6445fd685e3682ba3514470b4656e1933b8ad1e Mon Sep 17 00:00:00 2001 From: PeterNashaat Date: Wed, 22 May 2024 08:47:08 +0000 Subject: [PATCH 4/8] workflow add --install to install service if not found --- .github/workflows/staging.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index a001845..1041520 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -32,4 +32,4 @@ jobs: mkdir ${HOME}/.kube echo ${{ secrets.TF_KUBE_CONFIG }} | base64 --decode > ${HOME}/.kube/config - name: deploy or upgrade new to kubernetes threefoldconnect-staging - run: helm upgrade news helm_files --set image.tag=${{ github.sha }} -n threefoldconnect-staging + run: helm upgrade news --install helm_files --set image.tag=${{ github.sha }} -n threefoldconnect-staging From 242f24462d8ad6a24e3cb2ef63998aaee125cdb2 Mon Sep 17 00:00:00 2001 From: PeterNashaat Date: Wed, 22 May 2024 09:01:18 +0000 Subject: [PATCH 5/8] adding staging values file --- helm_files/valuesStaging.yaml | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 helm_files/valuesStaging.yaml diff --git a/helm_files/valuesStaging.yaml b/helm_files/valuesStaging.yaml new file mode 100755 index 0000000..e7db5f6 --- /dev/null +++ b/helm_files/valuesStaging.yaml @@ -0,0 +1,36 @@ +replicaCount: 1 + +environment: staging + +image: + name: news-staging + repo: threefolddev/staging-threefold-connect-news + tag: latest + containerPort: 80 + +service: + port: 80 + targetPort: 80 + +ingress: + hosts: + - name: news.staging.threefold.me + path: / + service: news-staging + port: 80 + + + + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + + +acme: + email: operations@threefold.io From 4a04496bd324c66b013468f58b1aa0c28dc952ba Mon Sep 17 00:00:00 2001 From: PeterNashaat Date: Wed, 22 May 2024 09:14:35 +0000 Subject: [PATCH 6/8] adding staging values file --- helm_files/{values.yaml => valuesProduction.yaml} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename helm_files/{values.yaml => valuesProduction.yaml} (91%) diff --git a/helm_files/values.yaml b/helm_files/valuesProduction.yaml similarity index 91% rename from helm_files/values.yaml rename to helm_files/valuesProduction.yaml index 1319564..a1a98d6 100755 --- a/helm_files/values.yaml +++ b/helm_files/valuesProduction.yaml @@ -4,7 +4,7 @@ environment: prod image: name: news-prod - repo: threefoldjimber/threefold-connect-news + repo: threefolddev/threefold-connect-news tag: latest containerPort: 80 @@ -41,4 +41,4 @@ serviceAccount: acme: - email: laudr1997@gmail.com + email: operations@threefold.io From 448e3fbb8f53c77c63e0e9a8e4ec5727165b424f Mon Sep 17 00:00:00 2001 From: PeterNashaat Date: Wed, 22 May 2024 09:26:35 +0000 Subject: [PATCH 7/8] adding staging values file --- .github/workflows/staging.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index 1041520..3afcc7c 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -32,4 +32,4 @@ jobs: mkdir ${HOME}/.kube echo ${{ secrets.TF_KUBE_CONFIG }} | base64 --decode > ${HOME}/.kube/config - name: deploy or upgrade new to kubernetes threefoldconnect-staging - run: helm upgrade news --install helm_files --set image.tag=${{ github.sha }} -n threefoldconnect-staging + run: helm upgrade news --install helm_files -f helm_files/valuesStaging.yaml --set image.tag=${{ github.sha }} -n threefoldconnect-staging From cc1d9f96e4bbdbba2bd2b736a88d9cfeedf9ea39 Mon Sep 17 00:00:00 2001 From: hossnys Date: Thu, 30 May 2024 11:11:05 +0300 Subject: [PATCH 8/8] update production workflow --- .github/workflows/main.yml | 39 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ffad6e5..dab0f73 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,24 +11,22 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - name: Log into Docker Hub Registry + uses: docker/login-action@v2 + with: + username: ${{ secrets.TFDOCKERHUB_USERNAME }} + password: ${{ secrets.TFDOCKERHUB_PASSWORD }} + - name: Build the Docker image - run: docker build . --file Dockerfile --tag threefoldjimber/threefold-connect-news:${{ github.sha }} - - name: Log into GitHub Container Registry - run: echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin + run: docker build . -t threefolddev/threefold-connect-news:${{ github.sha }} + - name: Push to dockerhub - run: docker push threefoldjimber/threefold-connect-news:${{ github.sha }} + run: docker push threefolddev/threefold-connect-news:${{ github.sha }} - name: Push latest to dockerhub run: | - docker tag threefoldjimber/threefold-connect-news:${{ github.sha }} threefoldjimber/threefold-connect-news:latest - docker push threefoldjimber/threefold-connect-news:latest - # deploy: - # needs: [build] - # runs-on: whale-replacement - # steps: - # - name: remove current running container - # run: docker rm -f threefold-connect-news - # - name: run container - # run: docker run -d --restart unless-stopped --name threefold-connect-news --network 3proxynet threefoldjimber/threefold-connect-news:${{ github.sha }} + docker tag threefolddev/threefold-connect-news:${{ github.sha }} threefolddev/threefold-connect-news:latest + docker push threefolddev/threefold-connect-news:latest + deploy: @@ -39,13 +37,6 @@ jobs: - name: Create kubeconfig run: | mkdir ${HOME}/.kube - echo ${{ secrets.KUBE_KEY }} | base64 --decode > ${HOME}/.kube/jimber-prod2.key - echo ${HOME}/.kube/jimber-prod2.key - echo ${{ secrets.KUBE_CRT }} | base64 --decode > ${HOME}/.kube/jimber-prod2.crt - echo ${HOME}/.kube/jimber-prod2.crt - - name: context - run: | - echo ${{ secrets.KUBE_CONFIG }} | base64 --decode > ${HOME}/.kube/config - cat ${HOME}/.kube/config - - name: deploy to kubernetes - run: helm upgrade news helm_files --set image.tag=${{ github.sha }} -n jimber + echo ${{ secrets.TF_KUBE_CONFIG }} | base64 --decode > ${HOME}/.kube/config + - name: deploy to kubernetes jimber namespace + run: helm upgrade news --install helm_files -f helm_files/valuesProduction.yaml --set image.tag=${{ github.sha }} -n jimber