Skip to content

thewoolleyman/example-sshd-http-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Example sshd and HTTP server App

DISCLAIMER: This image is solely for example purposes, it may not be maintained or continue working.

This project contains the following:

Developer notes

Building the image

  • Create a buildx builder for multiplatform builds (linux and MacOS) docker buildx create --use
  • Create a multiplatform build (for publishing to registry): docker buildx build --platform linux/amd64,linux/arm64 -t example-sshd-http-app .
  • Also create a single-platform arm64 (MacOS) build, with --load option, to support local testing: docker buildx build --platform linux/arm64 -t example-sshd-http-app-arm64 --load .

Testing the image locally

  • Run the container locally: docker run -it -p 8022:22 -p 8000:8000 --name local-sshd-http-app example-sshd-http-app-arm64 /bin/bash
    • -p 8022:22 maps the container's port 22 (sshd) to the host's port 8022
    • -p 8000:8000 maps the container's port 8000 (web server) to the host's port 8000
  • Connect to the container via bash: docker exec -it local-sshd-http-app /bin/bash
    • Run sshd daemonized: /usr/sbin/sshd
    • Run the HTTP server in the background: nohup /usr/local/bin/server.sh > /tmp/server.log 2>&1 &
    • Tail the http server log: tail -f /tmp/server.log
  • Test connecting to container via SSH from docker host machine: ssh -p 8022 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null gitlab-workspaces@localhost
    • Connection should be successful with no password required.
  • Test connecting to the container via HTTP from docker host machine. Access http://localhost:8000 in a browser
  • Remove the container: docker rm -f local-sshd-http-app

Publish the image to registry and verify

Running the image in GitLab Workspaces

  • Open this project from https://gitlab.com/gitlab-org/workspaces/examples/example-sshd-http-app, or...
  • ...push it to a new project in your local GDK:
    • Create example-sshd-http-app project in GDK under gitlab-org, with no repo (no README)
    • From local machine: git remote add gdk ssh://[email protected]:2222/gitlab-org/example-sshd-http-app.git
    • Push to GDK: git push gdk main:main
  • Create a new workspace for the project.
  • NOTE: Currently, the gitlab-workspaces-tools container image does not support ARM64 (MacOS) architecture. To work around this in local GDK, you can locally edit tools_injector_image in ee/lib/remote_development/settings/default_settings.rb to have the following value: registry.gitlab.com/gitlab-org/workspaces/testing/gitlab-workspaces-tools-arm-fork:arm64-latest. Then, gdk restart rails-web, and create a new workspace for the example-sshd-http-app project.

Debugging SSH connection issues

In the tooling container

  • Get workspace's namespace name: kubectl get namespace
  • Get pod name: kubectl get pods -n <namespace name>
  • Exec into workspaces tooling container: kubectl exec -it <pod name> -n <namespace name> -- /bin/bash
  • ps -ef | grep sshd to check if sshd is running
  • To see logs, kill -9 the /usr/bin/sshd PID, then run /usr/sbin/sshd -d -D to see sshd server output to console (TODO: Not sure where default logs go, find them and update this).

In the gitlab-workspaces-proxy container

  • Get gitlab-workspaces-proxy pod name: kubectl get pods -n gitlab-workspaces
  • Tail the logs of the container: kubectl logs -f gitlab-workspaces-proxy-79d845b49-hlxnv -c gitlab-workspaces-proxy -n gitlab-workspaces

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published