Sign inSign up

viharm/ungit

By viharm

Updated about 3 years ago

Ungit, containerized.

Image
0

285

viharm/ungit repository overview

Deprecation Notice

THIS IMAGE REPOSITORY HAS BEEN MOVED TO https://hub.docker.com/r/cerebralvoyage/ungit-docker/

ALL FURTHER UPDATES WILL BE AVAILABLE AT THE NEW LOCATION.

PLEASE AVOID USING THIS REPOSITORY.

IMAGES ARE CURRENTLY LEFT ON THIS REPO TO AVOID BREAKING LINKS HOWEVER ONCE A NEW UNGIT VERSION IS RELEASED, ALL IMAGES ON THIS REPOSITORY WILL BE DELETED TO PREVENT ANYONE FROM DOWNLOADING OBSOLETE IMAGES.


This is a simple image for deploying Ungit as a self-hosted web app.

Approach

Since Ungit is a Node application, which also runs Git commands in the backend, the following approach has been used:

  1. Start with an Alpine-based Nodejs image
  2. Install Git, GPG & GPG-Agent from using Alpine's built-in package manager (apk)
  3. Install Ungit using NPM
  4. Expose Ungit's operating port (8448)
  5. Switch to the working directory - assumed to be /var/local/ungit/

You can build it yourself if you wish. Here's the Dockerfile

  FROM node:20.5.1-alpine3.18
  RUN apk add --no-cache git gpg gpg-agent && rm -vrf /var/cache/apk/*
  RUN  npm install ungit@latest -g && npm cache clean --force
  EXPOSE 8448
  WORKDIR /var/local/ungit

Ungit's launch command hasn't been baked into the image to allow tweaking by the user.

Ideally, the user can launch a VS Code Server image, running as the same user, and use the same directory where the code rests to have an IDE + Git client. You can go one step further by having an instance of Caddy using the code repo as the HTML directory, also running as the same user.

Deployment

To deploy the container as a stack, the following requirements must be met:

  1. The user who owns the code repositories must be running the container.
  2. The home directory of the user must be mapped to /home/node/ in the container. The environment variable HOME must be overriden with this path, since the running user may not exist inside the container.
  3. Ungit's bind IP must be set to 0.0.0.0 as part of the launch command to ensure that it can be accessed from outside the container.

Here's a sample Docker Compose file

version: '3'
name: "ungit"


services:

  main:

    container_name: "Ungit"
    restart: "unless-stopped"

    deploy:
      resources:
        limits:
          cpus: "0.25"
          memory: "256m"

    user: "${UID}:${GID}"

    healthcheck:
      test: "/usr/bin/wget --no-verbose --quiet --tries=1 --spider http://localhost:8448 || exit 1"
      interval: "60s"
      timeout: "10s"
      start_period: "20s"
      retries: 3

    networks:
      net_app:
        ipv4_address: "172.24.70.2"
    hostname: "ungit"
    extra_hosts:
      - "dockerhost:172.24.70.1"
#   ports:
#     - target: 8448
#       host_ip: "0.0.0.0"
#       published: 8448
#       protocol: "tcp"
#       mode: "host"

    volumes:
      - type: "bind"
        source: "/etc/localtime"
        target: "/etc/localtime"
        read_only: true
      - type: "bind"
        source: "/home/username"
        target: "/home/node"
        read_only: false
      - type: "bind"
        source: "/var/local/CodeRepo/Data"
        target: "/var/local/ungit"
        read_only: false

    environment:
      TZ: "Europe/London"
      HOME: "/home/node"

    image: "viharm/ungit:1.1.0_node-20.5.1_git-2.40.1_ungit-1.5.24"

    command:
      - "ungit"
      - "--logLevel=warn" # "none" < "error" < "warn" < "info" < "verbose" < "debug" < "silly"
      - "--ungitBindIp=0.0.0.0"
      - "--forcedLaunchPath=\"/var/local/ungit\""
      - "--no-launchBrowser"
      - "--no-bugTracking"
      - "--no-autoFetch"
      - "--tabSize=2"


networks:
  net_app:
    name: "Ungit_net"
    driver: "bridge"
    ipam:
      driver: "default"
      config:
        - subnet: "172.24.70.0/24"

Then serve this via a reverse proxy or expose the ports (uncomment above) for direct use. Remember to apply the appropriate authentication. I use Authelia.

References

  1. https://nodejs.org/en/docs/guides/nodejs-docker-webapp
  2. https://dockerlabs.collabnix.com/beginners/dockerfile/lab1_dockerfile_git.html
  3. https://stackoverflow.com/a/49119046
  4. https://coder-coder.com/npm-clear-cache/
  5. https://github.com/FredrikNoren/ungit/blob/master/source/config.js
  6. https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#non-root-user

Tag summary

Content type

Image

Digest

sha256:74c43a17c

Size

91.5 MB

Last updated

about 3 years ago

docker pull viharm/ungit