y
Size: a a a
y
A
AP
SP
SP
SP
AP
SP
O
O
O
image: docker:latest
services:
- docker:dind
stages:
- build
- deploy
before_script:
- echo "Before script..."
- echo $CI_REGISTRY_USER
- echo $CI_REGISTRY_PASSWORD
- echo $CI_REGISTRY
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
# Setup SSH deploy keys
- 'which ssh-agent || ( apk --update add openssh-client )'
- eval $(ssh-agent -s)
- echo -e "$SSH_PRIVATE_KEY" > key
- chmod 600 key
- ssh-add key
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
build:
stage: build
script:
- docker pull $CI_REGISTRY_IMAGE:latest || true
- docker build --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA --tag $CI_REGISTRY_IMAGE:latest .
# - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
- docker push $CI_REGISTRY_IMAGE:latest
only:
- develop
deploy:
stage: deploy
script:
- ls ~/.ssh/
- ssh alazhar_domain@34.87.6.133 /bin/bash "ls"
only:
- develop
GG
GG
GG
O
O
$ ssh alazhar_domain@34.87.6.133 /bin/bash "cd docker && docker-compose up"The idea is after logging in to the server via ssh, I want to go to my /docker directory and execute docker-compose up
Warning: Permanently added '34.87.6.133' (ECDSA) to the list of known hosts.
/bin/bash: cd: No such file or directory
GG
bash -c "here_goes_long_command"