Skip to content

Commit

Permalink
fix ssh command
Browse files Browse the repository at this point in the history
  • Loading branch information
reschandreas committed Dec 26, 2023
1 parent c758c63 commit d2075df
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 25 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build-and-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
paths-ignore:
- "README.md"
- ".github/workflows/python-**.yaml"
- ".github/workflows/deploy-**.yaml"
- ".github/workflows/json-schema-generation.yaml"

env:
REGISTRY: ghcr.io
Expand Down Expand Up @@ -40,6 +42,7 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
- name: Fetch Aeolus Deployment CLI
run: |
wget ${{ env.RAW_URL }}/deployment/aeolus-deployment
wget ${{ env.RAW_URL }}/deployment/aeolus-docker
chmod +x aeolus-deployment
# Configure SSH Key
Expand All @@ -69,17 +70,16 @@ jobs:
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
ssh -J "$DEPLOYMENT_USER@$DEPLOYMENT_HOST" "$DEPLOYMENT_USER@$DEPLOYMENT_HOST" "mkdir -p $DEPLOYMENT_DIRECTORY"
ssh -J "$GATEWAY_USER@$GATEWAY_HOST" "$DEPLOYMENT_USER@$DEPLOYMENT_HOST" "mkdir -p $DEPLOYMENT_DIRECTORY"
- name: Copy deployment scripts
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
ls -lah
scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=~/.ssh/known_hosts -o ProxyJump="$GATEWAY_USER@$GATEWAY_HOST" -r deployment "$DEPLOYMENT_USER@$DEPLOYMENT_HOST:$DEPLOYMENT_DIRECTORY"
scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=~/.ssh/known_hosts -o ProxyJump="$GATEWAY_USER@$GATEWAY_HOST" aeolus-docker "$DEPLOYMENT_USER@$DEPLOYMENT_HOST:$DEPLOYMENT_DIRECTORY"
- name: Deploy Aeolus with Docker
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
$DEPLOYMENT_DIRECTORY/deployment/aeolus-deployment docker-deploy "$DEPLOYMENT_USER@$DEPLOYMENT_HOST" -g "$GATEWAY_USER@$GATEWAY_HOST" -t $DOCKER_TAG -b $BRANCH_NAME -d $DEPLOYMENT_DIRECTORY -y
./aeolus-deployment docker-deploy "$DEPLOYMENT_USER@$DEPLOYMENT_HOST" -g "$GATEWAY_USER@$GATEWAY_HOST" -t $DOCKER_TAG -b $BRANCH_NAME -d $DEPLOYMENT_DIRECTORY -y
2 changes: 1 addition & 1 deletion cli/generators/jenkins.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def handle_always_step(self, name: str, step: ScriptAction, indentation: int = 4
self.add_script(
wrapper="post",
name=name,
original_type=original_type,
original_type="custom",
script=script,
indentation=indentation,
workdir=None,
Expand Down
3 changes: 1 addition & 2 deletions deployment/aeolus-deployment
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ function docker_deploy {

ssh -J "$_gateway_host" -o "StrictHostKeyChecking=no" "$_deployment_host" << COMMAND
mkdir -p $_deployment_directory
cd $_deployment_directory
sudo /usr/bin/bash $_deployment_directory/pyris-docker.sh restart $3 $4
/usr/bin/bash $_deployment_directory/aeolus-docker restart $_pr_tag $_pr_branch
COMMAND
}

Expand Down
21 changes: 14 additions & 7 deletions deployment/aeolus-docker
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Adapted from https://github.com/ls1intum/Pyris
# this script is used to start the Aeolus docker containers, and must be available on the deployment server

PROJECT_DIR="/opt/aeolus/deployment"
PROJECT_DIR="/opt/aeolus/Aeolus/deployment"
COMPOSE_FILE="traefik/docker-compose.yml"
ENV_FILE="/opt/aeolus/docker.env"

Expand All @@ -26,17 +26,24 @@ function start {
local pr_branch=$2

echo "Starting aeolus with PR tag: $pr_tag and branch: $pr_branch"
rm -rf Pyris
rm -rf Aeolus
git clone https://github.com/ls1intum/Aeolus.git -b "$pr_branch" Aeolus
sed -i "s/AEOLUS_DOCKER_TAG=.*/AEOLUS_DOCKER_TAG='$pr_tag'/g" $ENV_FILE
docker compose --project-directory "$PROJECT_DIR" -f "$PROJECT_DIR/$COMPOSE_FILE" --env-file "$ENV_FILE" up -d --pull always --no-build
if [ ! -f "$PROJECT_DIR/traefik/acme.json" ]; then
touch "$PROJECT_DIR/traefik/acme.json"
chmod 600 "$PROJECT_DIR/traefik/acme.json"
fi
if [ ! -f "$PROJECT_DIR/traefik/traefik.log" ]; then
touch "$PROJECT_DIR/traefik/traefik.log"
fi
docker compose -f "$PROJECT_DIR/$COMPOSE_FILE" --env-file "$ENV_FILE" up -d --pull always --no-build
}

function stop {
# TODO: In the future extract pr_tag and pr_branch from env

echo "Stopping aeolus"
docker compose --project-directory "$PROJECT_DIR" -f "$PROJECT_DIR/$COMPOSE_FILE" --env-file "$ENV_FILE" stop pyris-app
docker compose -f "$PROJECT_DIR/$COMPOSE_FILE" --env-file "$ENV_FILE" down
}

function restart {
Expand All @@ -45,15 +52,15 @@ function restart {
}

function aeolus_logs {
docker compose --project-directory "$PROJECT_DIR" -f "$PROJECT_DIR/$COMPOSE_FILE" --env-file "$ENV_FILE" logs -f aeolus-api
docker compose -f "$PROJECT_DIR/$COMPOSE_FILE" --env-file "$ENV_FILE" logs -f aeolus-api
}

function all_logs {
docker compose --project-directory "$PROJECT_DIR" -f "$PROJECT_DIR/$COMPOSE_FILE" --env-file "$ENV_FILE" logs -f
docker compose -f "$PROJECT_DIR/$COMPOSE_FILE" --env-file "$ENV_FILE" logs -f
}

function run_docker_compose_cmd {
docker compose --project-directory "$PROJECT_DIR" -f "$PROJECT_DIR/$COMPOSE_FILE" --env-file "$ENV_FILE" "$@"
docker compose -f "$PROJECT_DIR/$COMPOSE_FILE" --env-file "$ENV_FILE" "$@"
}

# read subcommand `aeolus-docker subcommand server` in variable and remove base command from argument list
Expand Down
4 changes: 2 additions & 2 deletions deployment/traefik/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
labels:
- "traefik.enable=true"
- "traefik.docker.network=traefik"
- 'traefik.http.routers.aeolus-playground.rule=(HostRegexp(`{host:.+}`) && !PathPrefix("/api"))'
- 'traefik.http.routers.aeolus-playground.rule=(Host(`${AEOLUS_HOST}`) && !PathPrefix("/api"))'
- "traefik.http.routers.aeolus-playground.entrypoints=https"
- "traefik.http.routers.aeolus-playground.tls=true"
- "traefik.http.routers.aeolus-playground.tls.certResolver=leresolver"
Expand All @@ -26,7 +26,7 @@ services:
labels:
- "traefik.enable=true"
- "traefik.docker.network=traefik"
- 'traefik.http.routers.aeolus-api.rule=(HostRegexp(`{host:.+}`) && PathPrefix("/api"))'
- 'traefik.http.routers.aeolus-api.rule=(Host(`${AEOLUS_HOST}`) && PathPrefix("/api"))'
- "traefik.http.routers.aeolus-api.entrypoints=https"
- "traefik.http.routers.aeolus-api.tls=true"
- "traefik.http.routers.aeolus-api.tls.certResolver=leresolver"
Expand Down
15 changes: 6 additions & 9 deletions deployment/traefik/traefik.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
log:
level: DEBUG
filePath: /traefik.log
docker:
watch: true
exposedbydefault: false
providers:
docker:
endpoint: unix:///var/run/docker.sock
file:
filename: /traefik-provider.yaml
certificatesResolvers:
leresolver:
acme:
email: [email protected]
storage: acme.json
tlsChallenge: {}
entryPoints:
http:
address: :80/tcp
Expand All @@ -22,10 +25,4 @@ entryPoints:
http:
tls:
certResolver: leresolver
certificatesResolvers:
leresolver:
acme:
email: [email protected]
storage: acme.json
tlsChallenge: {}
retry: {}

0 comments on commit d2075df

Please sign in to comment.