Skip to content

Commit

Permalink
sample golang apps
Browse files Browse the repository at this point in the history
  • Loading branch information
kcq committed Feb 5, 2018
1 parent 6886306 commit 1a1366b
Show file tree
Hide file tree
Showing 22 changed files with 142 additions and 2 deletions.
10 changes: 8 additions & 2 deletions README.md
Expand Up @@ -304,7 +304,7 @@ It's used to minify the `container-transform` tool. You can get the minified ima

## CURRENT STATE

It works pretty well with the sample Node.js, Python (2 and 3), Ruby and Java images (built from `examples/apps`). More testing needs to be done to see how it works with other images. Rails/unicorn app images are not fully supported yet (WIP).
It works pretty well with the sample Node.js, Python (2 and 3), Ruby, Java and Golang images (built from `examples/apps`). More testing needs to be done to see how it works with other images. Rails/unicorn app images are not fully supported yet (WIP).

Sample images (built with the standard Ubuntu 14.04 base image):

Expand All @@ -318,11 +318,17 @@ Sample images built with Alpine:
* nodejs app container: 66.4 MB => 34.7 MB
* python app container: 86 MB => 22.1 MB

Sample Golang application images:

* from golang:latest: 700MB => 1.55MB
* from ubuntu:14.04: 529MB => 1.86MB
* from golang:alpine: 258MB => 1.55MB

You can also run `docker-slim` in the `info` mode and it'll generate useful image information including a "reverse engineered" Dockerfile.

DockerSlim now also generates Seccomp (usable) and AppArmor (WIP) profiles for your container.

Works with Docker 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 17.03.
Works with Docker 1.8 - 1.9, 1.10, 1.11, 1.12, 1.13, 17.03, 17.12.

Note:

Expand Down
6 changes: 6 additions & 0 deletions examples/apps/golang_alpine/Dockerfile
@@ -0,0 +1,6 @@
FROM golang:alpine
WORKDIR /app
ADD . /app
RUN cd /app && go build -o app

ENTRYPOINT ["/app/app"]
7 changes: 7 additions & 0 deletions examples/apps/golang_alpine/app.go
@@ -0,0 +1,7 @@
package main

import "fmt"

func main() {
fmt.Println("Sample golang app (alpine)")
}
5 changes: 5 additions & 0 deletions examples/apps/golang_alpine/build.command
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

here="$(dirname "$BASH_SOURCE")"
cd $here
docker build -t my/golang-app-alpine .
6 changes: 6 additions & 0 deletions examples/apps/golang_alpine/clean.command
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

here="$(dirname "$BASH_SOURCE")"
cd $here
docker rmi my/golang-app-alpine .
docker rmi my/golang-app-alpine.slim .
5 changes: 5 additions & 0 deletions examples/apps/golang_alpine/run_full.command
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

here="$(dirname "$BASH_SOURCE")"
cd $here
docker run --rm -it my/golang-app-alpine
5 changes: 5 additions & 0 deletions examples/apps/golang_alpine/run_slim.command
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

here="$(dirname "$BASH_SOURCE")"
cd $here
docker run --rm -it my/golang-app-alpine.slim
5 changes: 5 additions & 0 deletions examples/apps/golang_alpine/slim.command
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

here="$(dirname "$BASH_SOURCE")"
cd $here
docker-slim build my/golang-app-alpine
6 changes: 6 additions & 0 deletions examples/apps/golang_standard/Dockerfile
@@ -0,0 +1,6 @@
FROM golang:latest
WORKDIR /app
ADD . /app
RUN cd /app && go build -o app

ENTRYPOINT ["/app/app"]
7 changes: 7 additions & 0 deletions examples/apps/golang_standard/app.go
@@ -0,0 +1,7 @@
package main

import "fmt"

func main() {
fmt.Println("Sample golang app (standard)")
}
5 changes: 5 additions & 0 deletions examples/apps/golang_standard/build.command
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

here="$(dirname "$BASH_SOURCE")"
cd $here
docker build -t my/golang-app .
6 changes: 6 additions & 0 deletions examples/apps/golang_standard/clean.command
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

here="$(dirname "$BASH_SOURCE")"
cd $here
docker rmi my/golang-app .
docker rmi my/golang-app.slim .
5 changes: 5 additions & 0 deletions examples/apps/golang_standard/run_full.command
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

here="$(dirname "$BASH_SOURCE")"
cd $here
docker run --rm -it my/golang-app
5 changes: 5 additions & 0 deletions examples/apps/golang_standard/run_slim.command
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

here="$(dirname "$BASH_SOURCE")"
cd $here
docker run --rm -it my/golang-app.slim
5 changes: 5 additions & 0 deletions examples/apps/golang_standard/slim.command
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

here="$(dirname "$BASH_SOURCE")"
cd $here
docker-slim build my/golang-app
23 changes: 23 additions & 0 deletions examples/apps/golang_ubuntu/Dockerfile
@@ -0,0 +1,23 @@
FROM ubuntu:14.04

RUN apt-get update && \
apt-get install software-properties-common -y && \
add-apt-repository ppa:gophers/archive -y && \
apt-get update && \
apt-get install golang-1.9-go -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

ENV GOPATH /go
ENV GOROOT /usr/lib/go-1.9
ENV PATH /usr/lib/go-1.9/bin:/go/bin:/usr/local/bin:$PATH

WORKDIR /app
ADD . /app
RUN cd /app && go build -o app

ENTRYPOINT ["/app/app"]




7 changes: 7 additions & 0 deletions examples/apps/golang_ubuntu/app.go
@@ -0,0 +1,7 @@
package main

import "fmt"

func main() {
fmt.Println("Sample golang app (ubuntu)")
}
5 changes: 5 additions & 0 deletions examples/apps/golang_ubuntu/build.command
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

here="$(dirname "$BASH_SOURCE")"
cd $here
docker build -t my/golang-app-ubuntu .
6 changes: 6 additions & 0 deletions examples/apps/golang_ubuntu/clean.command
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

here="$(dirname "$BASH_SOURCE")"
cd $here
docker rmi my/golang-app-ubuntu
docker rmi my/golang-app-ubuntu.slim
5 changes: 5 additions & 0 deletions examples/apps/golang_ubuntu/run_full.command
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

here="$(dirname "$BASH_SOURCE")"
cd $here
docker run --rm -it my/golang-app-ubuntu
5 changes: 5 additions & 0 deletions examples/apps/golang_ubuntu/run_slim.command
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

here="$(dirname "$BASH_SOURCE")"
cd $here
docker run --rm -it my/golang-app-ubuntu.slim
5 changes: 5 additions & 0 deletions examples/apps/golang_ubuntu/slim.command
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

here="$(dirname "$BASH_SOURCE")"
cd $here
docker-slim build my/golang-app-ubuntu

0 comments on commit 1a1366b

Please sign in to comment.