Skip to content

Commit

Permalink
Merge pull request #6 from threefoldtech/staging
Browse files Browse the repository at this point in the history
merge latest changes on workflows to main
  • Loading branch information
hossnys authored May 30, 2024
2 parents a21e2af + cc1d9f9 commit 0df4f67
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 51 deletions.
39 changes: 15 additions & 24 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
35 changes: 35 additions & 0 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
@@ -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/staging-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 --install helm_files -f helm_files/valuesStaging.yaml --set image.tag=${{ github.sha }} -n threefoldconnect-staging
51 changes: 26 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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;"]
4 changes: 2 additions & 2 deletions helm_files/values.yaml → helm_files/valuesProduction.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ environment: prod

image:
name: news-prod
repo: threefoldjimber/threefold-connect-news
repo: threefolddev/threefold-connect-news
tag: latest
containerPort: 80

Expand Down Expand Up @@ -41,4 +41,4 @@ serviceAccount:


acme:
email: laudr1997@gmail.com
email: operations@threefold.io
36 changes: 36 additions & 0 deletions helm_files/valuesStaging.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0df4f67

Please sign in to comment.