Add git warehouse directly to dockerfile, support private and public warehouses

# syntax=docker/dockerfile:1-labs
FROM node:16.18
ENV DEV_ENV="DOCKER"
ENV AUTHOR = "Fizz"

WORKDIR /fizz-dev-workspace
 
ADD --keep-git-dir=true git@https://github.com/microsoft/monaco-editor.git /fizz-dev-workspace

RUN pwd && \
    ls -l && \
    # cd ./monaco-editor && \ 
    yarn
    

ssh agent

To ensure that your host has the SSH proxy service properly configured and running, you can follow these steps:

  1. First, make sure you have the SSH client and server installed on your host. On Windows, you can use OpenSSH as an SSH client and server.

  2. Open Windows PowerShell or Command Prompt and enter the following command to check if OpenSSH is installed:

    ssh -V
    

    If the version information of OpenSSH is displayed, it means the installation is successful. If it is not installed, please refer to the official documentation or download and install OpenSSH.

  3. Start the SSH agent service on the host. On Windows you can use the following command:

    ssh-agent
    

    This will start the SSH agent service and display the agent process ID in the console.

  4. Add SSH private key to the agent. Use the following command:

    ssh-add /path/to/private_key
    

    Replace /path/to/private_keywith the path to your SSH private key file.

    You may need to provide the password for the private key (if a password is set). After the private key is successfully added, a success message is displayed.

  5. Now, your host has the SSH proxy service properly configured and running. You can use an SSH proxy within a Docker container by forwarding SSH connections on the host machine.

    Note: Copying the SSH private key in the Dockerfile is a workaround, but this may not be secure enough as the private key will be exposed in the container. Enabling SSH proxy allows for a more secure connection.

Enable ssh agent under windows

If you get error 1058 when running under Windows ssh-agent, this is usually caused by the SSH agent service not being installed correctly or not starting. You can try the following workarounds:

  1. Confirm that OpenSSH is installed correctly: On Windows, you can use the following command to check if OpenSSH is installed:

    ssh -V
    

    If the version information of OpenSSH is displayed, it means the installation is successful. If it is not installed, please refer to the official documentation or download and install OpenSSH.

  2. Check whether the SSH agent service has been started in Windows Services. Press the Win + R key combination and enter to services.mscopen Service Manager.

  3. In the service manager, find the service named "OpenSSH Authentication Agent". Make sure the service's status is "Started". If the service is not started, right-click the service and select "Start".

  4. If the service is not installed or fails to start, you can try reinstalling or repairing OpenSSH. Please refer to OpenSSH's official documentation for detailed installation and configuration guides.

  5. Reopen Windows PowerShell or Command Prompt and try running ssh-agentthe command again:

    ssh-agent
    

    If everything is OK, the ID of the SSH agent process will be displayed.

If the problem persists, make sure you followed the correct installation and configuration steps and have the appropriate permissions to start the SSH Agent service. If you still can't solve the problem, I recommend referring to the official documentation of OpenSSH or asking for help in the relevant technical community.

Related Links

https://docs.docker.com/engine/reference/builder/#adding-a-git-repository-add-git-ref-dir

Guess you like

Origin blog.csdn.net/github_35631540/article/details/132036471