Created
December 2, 2022 21:00
-
-
Save yariksheptykin/98cde5bac81708bd99354890cab0254b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
db: | |
image: ubuntu:22.04 | |
volumes: | |
- "${SSH_AUTH_SOCK:?SSH configuration is incomplete}:/ssh-agent" | |
environment: | |
SSH_AUTH_SOCK: '/ssh-agent' | |
PROXY_SSH_SERVER: '${PROXY_SSH_SERVER:?SSH configuration is incomplete}' | |
PROXY_SSH_USER: '${PROXY_SSH_USER:?SSH configuration is incomplete}' | |
REMOTE_MYSQL_HOST: ${REMOTE_MYSQL_HOST:?Database configuration seems to be missing} | |
REMOTE_MYSQL_PORT: ${REMOTE_MYSQL_PORT:?Database configuration seems to be missing} | |
expose: | |
- '3306' | |
# ssh -o ExitOnForwardFailure=yes -f -N -L 0.0.0.0:3306:$$REMOTE_MYSQL_HOST:$$REMOTE_MYSQL_HOST $$PROXY_SSH_USER@$$PROXY_SSH_SERVER | |
command: | |
- bash | |
- -c | |
- >- | |
apt-get update -y && apt-get install -y openssh-client mysql-client; | |
mkdir -p ~/.ssh; chmod 700 ~/.ssh; | |
ssh-keygen -R $$PROXY_SSH_SERVER; ssh-keyscan -H $$PROXY_SSH_SERVER >> ~/.ssh/known_hosts; | |
ssh -o ExitOnForwardFailure=yes -N -L 0.0.0.0:3306:$$REMOTE_MYSQL_HOST:$$REMOTE_MYSQL_PORT $$PROXY_SSH_USER@$$PROXY_SSH_SERVER |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment