mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-23 23:51:03 +00:00
Reworked Dockerfile for a more production oriented usage
- Added .dockerignore to speed up build context and avoid rebuilding when unecessary - Specified Alpine and Go versions as build arguments - Specified Go target CPU architecture as build arguments to be able to build for ARM devices - Specified base images as build arguments to be able to build for ARM devices - Trimmed down size of final image using `-a -installsuffix cgo -ldflags="-s -w"` go build flags and by copying the statically built binary only to the final image - Added clear build and run instructions for the Docker container
This commit is contained in:
parent
a51bb830a5
commit
1542c70b53
3 changed files with 72 additions and 11 deletions
11
.dockerignore
Normal file
11
.dockerignore
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
.circleci
|
||||
.github
|
||||
docs
|
||||
test
|
||||
.gitignore
|
||||
.goreleaser.yml
|
||||
*.md
|
||||
coverage.txt
|
||||
Dockerfile
|
||||
LICENSE
|
||||
test.sh
|
||||
23
Dockerfile
23
Dockerfile
|
|
@ -1,15 +1,16 @@
|
|||
# run with:
|
||||
# docker build -t lazydocker .
|
||||
# docker run -it lazydocker:latest /bin/sh -l
|
||||
ARG BASE_IMAGE_BUILDER=golang
|
||||
ARG BASE_IMAGE=alpine
|
||||
ARG ALPINE_VERSION=3.10
|
||||
ARG GO_VERSION=1.12.6
|
||||
|
||||
FROM golang:alpine
|
||||
FROM ${BASE_IMAGE_BUILDER}:${GO_VERSION}-alpine${ALPINE_VERSION} AS builder
|
||||
ARG GOARCH=amd64
|
||||
ARG GOARM
|
||||
WORKDIR /go/src/github.com/jesseduffield/lazydocker/
|
||||
COPY ./ .
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${GOARCH} GOARM=${GOARM} go build -a -installsuffix cgo -ldflags="-s -w"
|
||||
|
||||
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}:${ALPINE_VERSION}
|
||||
RUN apk --update add -q --progress --no-cache -U git xdg-utils
|
||||
ENTRYPOINT [ "lazydocker" ]
|
||||
COPY --from=builder /go/src/github.com/jesseduffield/lazydocker/lazydocker /usr/bin/lazydocker
|
||||
|
|
|
|||
49
README.md
49
README.md
|
|
@ -48,6 +48,55 @@ required go version: 1.12
|
|||
go get github.com/jesseduffield/lazydocker
|
||||
```
|
||||
|
||||
### Docker
|
||||
|
||||
1. <details><summary>Build it...</summary><p>
|
||||
|
||||
- If you have a x86_64 CPU architecture
|
||||
|
||||
```sh
|
||||
docker build -t lazydocker . https://github.com/jesseduffield/lazydocker.git
|
||||
```
|
||||
|
||||
- If you have a ARM 32 bit v6 architecture
|
||||
|
||||
```sh
|
||||
docker build -t lazydocker \
|
||||
--build-arg BASE_IMAGE_BUILDER=arm32v6/golang \
|
||||
--build-arg BASE_IMAGE=arm32v6/alpine \
|
||||
--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 lazydocker \
|
||||
--build-arg BASE_IMAGE_BUILDER=arm32v7/golang \
|
||||
--build-arg BASE_IMAGE=arm32v7/alpine \
|
||||
--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 lazydocker \
|
||||
--build-arg BASE_IMAGE_BUILDER=arm64v8/golang \
|
||||
--build-arg BASE_IMAGE=arm64v8/alpine \
|
||||
--build-arg GOARCH=arm64 \
|
||||
https://github.com/jesseduffield/lazydocker.git
|
||||
```
|
||||
|
||||
</p></details>
|
||||
1. Run it
|
||||
|
||||
```sh
|
||||
docker run -it -v /var/run/docker.sock:/var/run/docker.sock lazydocker
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Call `lazydocker` in your terminal. I personally use this a lot so I've made an alias for it like so:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue