diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..af55e3c1 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,12 @@ +.circleci +.github +docs +test +.gitignore +.goreleaser.yml +*.md +coverage.txt +Dockerfile +LICENSE +test.sh +.git diff --git a/Dockerfile b/Dockerfile index c1badb7f..594f6e27 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,49 @@ -# run with: -# docker build -t lazydocker . -# docker run -it lazydocker:latest /bin/sh -l +ARG BASE_IMAGE_BUILDER=golang +ARG ALPINE_VERSION=3.10 +ARG GO_VERSION=1.12.6 -FROM golang:alpine -WORKDIR /go/src/github.com/jesseduffield/lazydocker/ +FROM ${BASE_IMAGE_BUILDER}:${GO_VERSION}-alpine${ALPINE_VERSION} AS builder +ARG GOARCH=amd64 +ARG GOARM +ARG VERSION +ARG VCS_REF +WORKDIR /tmp/gobuild COPY ./ . -RUN CGO_ENABLED=0 GOOS=linux go build +RUN CGO_ENABLED=0 GOOS=linux GOARCH=${GOARCH} GOARM=${GOARM} \ + go build -a -mod=vendor \ + -ldflags="-s -w \ + -X main.commit=${VCS_REF} \ + -X main.version=${VERSION} \ + -X main.buildSource=Docker" -FROM alpine:latest -RUN apk add -U git xdg-utils -WORKDIR /go/src/github.com/jesseduffield/lazydocker/ -COPY --from=0 /go/src/github.com/jesseduffield/lazydocker /go/src/github.com/jesseduffield/lazydocker -COPY --from=0 /go/src/github.com/jesseduffield/lazydocker/lazydocker /bin/ -RUN echo "alias gg=lazydocker" >> ~/.profile +FROM ${BASE_IMAGE_BUILDER}:${GO_VERSION}-alpine${ALPINE_VERSION} AS docker-builder +ARG GOARCH=amd64 +ARG GOARM +ARG DOCKER_VERSION=v18.09.7 +RUN apk add -U -q --progress --no-cache git bash coreutils gcc musl-dev +WORKDIR /go/src/github.com/docker/cli +RUN git clone --branch ${DOCKER_VERSION} --single-branch --depth 1 https://github.com/docker/cli.git . > /dev/null 2>&1 +ENV CGO_ENABLED=0 \ + GOARCH=${GOARCH} \ + GOARM=${GOARM} \ + DISABLE_WARN_OUTSIDE_CONTAINER=1 +RUN ./scripts/build/binary +RUN rm build/docker && mv build/docker-linux-* build/docker + +FROM scratch +ARG BUILD_DATE +ARG VCS_REF +ARG VERSION +LABEL \ + org.opencontainers.image.authors="jessedduffield@gmail.com" \ + org.opencontainers.image.created=$BUILD_DATE \ + org.opencontainers.image.version=$VERSION \ + org.opencontainers.image.revision=$VCS_REF \ + org.opencontainers.image.url="https://github.com/jesseduffield/lazydocker" \ + org.opencontainers.image.documentation="https://github.com/jesseduffield/lazydocker" \ + org.opencontainers.image.source="https://github.com/jesseduffield/lazydocker" \ + org.opencontainers.image.title="lazydocker" \ + org.opencontainers.image.description="The lazier way to manage everything docker" +ENTRYPOINT [ "/bin/lazydocker" ] +COPY --from=docker-builder /go/src/github.com/docker/cli/build/docker /bin/docker +COPY --from=builder /tmp/gobuild/lazydocker /bin/lazydocker \ No newline at end of file diff --git a/README.md b/README.md index 763c6276..289b0f80 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,81 @@ makepkg --install A development version of the AUR package is also [available](https://aur.archlinux.org/lazydocker-git.git) +### Docker + +[![Docker Pulls](https://img.shields.io/docker/pulls/lazyteam/lazydocker.svg)](https://hub.docker.com/r/lazyteam/lazydocker) +[![Docker Stars](https://img.shields.io/docker/stars/lazyteam/lazydocker.svg)](https://hub.docker.com/r/lazyteam/lazydocker) +[![Docker Automated](https://img.shields.io/docker/cloud/automated/lazyteam/lazydocker.svg)](https://hub.docker.com/r/lazyteam/lazydocker) + +1.
Click if you have an ARM device

+ + - If you have a ARM 32 bit v6 architecture + + ```sh + docker build -t lazyteam/lazydocker \ + --build-arg BASE_IMAGE_BUILDER=arm32v6/golang \ + --build-arg GOARCH=arm \ + --build-arg GOARM=6 \ + https://github.com/jesseduffield/lazydocker.git + ``` + + - If you have a ARM 32 bit v7 architecture + + ```sh + docker build -t lazyteam/lazydocker \ + --build-arg BASE_IMAGE_BUILDER=arm32v7/golang \ + --build-arg GOARCH=arm \ + --build-arg GOARM=7 \ + https://github.com/jesseduffield/lazydocker.git + ``` + + - If you have a ARM 64 bit v8 architecture + + ```sh + docker build -t lazyteam/lazydocker \ + --build-arg BASE_IMAGE_BUILDER=arm64v8/golang \ + --build-arg GOARCH=arm64 \ + https://github.com/jesseduffield/lazydocker.git + ``` + +

+ +1. Run the container + + ```sh + docker run -it -v \ + /var/run/docker.sock:/var/run/docker.sock \ + -v /yourpath:/.config/jesseduffield/lazydocker \ + lazyteam/lazydocker + ``` + + - Don't forget to change `/yourpath` to an actual path you created to store lazydocker's config + - You can also use this [docker-compose.yml](https://github.com/jesseduffield/lazydocker/blob/master/docker-compose.yml) + - You might want to create an alias, for example: + + ```sh + echo "alias ld='docker run -it -v /var/run/docker.sock:/var/run/docker.sock -v /yourpath/config:/.config/jesseduffield/lazydocker lazyteam/lazydocker'" >> ~/.zshrc + ``` + + + +For development, you can build the image using: + +```sh +git clone https://github.com/jesseduffield/lazydocker.git +cd lazydocker +docker build -t lazyteam/lazydocker \ + --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ + --build-arg VCS_REF=`git rev-parse --short HEAD` \ + --build-arg VERSION=`git describe --abbrev=0 --tag` \ + . +``` + +If you encounter a compatibility issue with Docker bundled binary, try rebuilding +the image with the build argument `--build-arg DOCKER_VERSION="v$(docker -v | cut -d" " -f3 | rev | cut -c 2- | rev)"` +so that the bundled docker binary matches your host docker binary version. + + ## Usage Call `lazydocker` in your terminal. I personally use this a lot so I've made an alias for it like so: diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..a7e23aa1 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,16 @@ +version: '3' +services: + lazydocker: + build: + context: https://github.com/jesseduffield/lazydocker.git + args: + BASE_IMAGE_BUILDER: golang + GOARCH: amd64 + GOARM: + image: jesseduffield/lazydocker + container_name: lazydocker + stdin_open: true + tty: true + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - ./config:/.config/jesseduffield/lazydocker \ No newline at end of file diff --git a/hooks/build b/hooks/build new file mode 100644 index 00000000..17973ef3 --- /dev/null +++ b/hooks/build @@ -0,0 +1,6 @@ +#!/bin/bash + +docker build --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ + --build-arg VCS_REF=`git rev-parse --short HEAD` \ + --build-arg VERSION=`git describe --abbrev=0 --tag` \ + -t $IMAGE_NAME . diff --git a/pkg/app/app.go b/pkg/app/app.go index 5edc6488..ffc73494 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -52,7 +52,6 @@ func NewApp(config *config.AppConfig) (*App, error) { func (app *App) Run() error { err := app.Gui.RunWithSubprocesses() - return err }