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 diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml new file mode 100644 index 0000000..3afcc7c --- /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/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 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;"] 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 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