Skip to content

Commit

Permalink
Test deployment with ssh
Browse files Browse the repository at this point in the history
  • Loading branch information
Daanvm committed Oct 12, 2024
1 parent 3add7ef commit 3f650a9
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 108 deletions.
2 changes: 0 additions & 2 deletions .dockerignore

This file was deleted.

56 changes: 0 additions & 56 deletions .github/workflows/deploy-strato.yaml

This file was deleted.

78 changes: 30 additions & 48 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,69 +2,51 @@ on:
push:
branches:
- master
- deploy-strato

jobs:
build:
name: Build Docker images
name: Build website .tar.gz
runs-on: ubuntu-latest
steps:
- name: Checkout master
uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: daanvm
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push christelmusic.nl-nginx
id: docker_build_christelmusic_nl_nginx
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile-nginx
push: true
tags: daanvm/christelmusic.nl-nginx:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build .tar.gz file
run: |
docker build --tag local-img/zipper --target zipper .
docker create --name zipper local-img/zipper
docker cp zipper:/build.tar.gz ./build.tar.gz
docker rm -f zipper
shell: bash

- name: Build and push christelmusic.nl-php
id: docker_build_christelmusic_nl_php
uses: docker/build-push-action@v3
- uses: actions/upload-artifact@v4
with:
context: .
file: ./Dockerfile
push: true
tags: daanvm/christelmusic.nl-php:latest
cache-from: type=gha
cache-to: type=gha,mode=max
name: build-tar-gz
path: ./build.tar.gz

deploy-kubernetes:
name: Create Kubernetes resources
deploy:
name: Deploy website to Strato
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout master
uses: actions/checkout@v3

- name: Install doctl
uses: digitalocean/action-doctl@v2
- uses: actions/download-artifact@v4
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
name: build-tar-gz

- name: Save DigitalOcean kubeconfig with short-lived credentials
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 k8s-daanvm
- name: Extract .tar.gz file
run: |
tar -xzvf build.tar.gz
rm build.tar.gz
shell: bash

- name: Create kubernetes resources
- name: Apt install sshpass
run: |
kubectl apply -f ./christelmusic.nl.yaml
sudo apt-get update
sudo apt-get -y install sshpass
- name: Deploy new latest version of docker image
- name: Upload to Strato
env:
SSHPASS: ${{ secrets.STRATO_SSH_PASSWORD }}
run: |
kubectl create secret generic ifttt --save-config --dry-run=client --from-literal='key=${{ secrets.IFTTT_KEY }}' -o yaml | kubectl apply -f -
kubectl create secret generic mail-orders-to --save-config --dry-run=client --from-literal='key=${{ secrets.MAIL_ORDERS_TO }}' -o yaml | kubectl apply -f -
kubectl rollout restart deployment christelmusic-nl
kubectl rollout restart deployment christelmusic-nl-php
sshpass -e scp -oStrictHostKeyChecking=no ./build.tar.gz ${{ secrets.STRATO_SSH_USERNAME }}@ssh.strato.com/new-release.tar.gz
sshpass -e ssh -oStrictHostKeyChecking=no ${{ secrets.STRATO_SSH_USERNAME }}@ssh.strato.com ls -lah
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@ RUN chmod uga+x /usr/local/bin/install-php-extensions && sync && \

# Install composer dependencies
COPY --from=composer /usr/bin/composer /usr/bin/composer
COPY app/composer.* /usr/src/build/
WORKDIR /var/www/html
RUN composer install

# Allow the creation of pdf files
RUN sed -i '/disable ghostscript format types/,+6d' /etc/ImageMagick-6/policy.xml

# Create cache
RUN /var/www/html/scripts/christelmusic warmup

FROM builder as zipper

RUN cd /var/www/html/ && tar --exclude-vcs-ignores -czvf /build.tar.gz ./*
RUN cd /var/www/ && tar -czvf /build.tar.gz html

FROM base

Expand Down

0 comments on commit 3f650a9

Please sign in to comment.