Skip to content

Instantly share code, notes, and snippets.

package main
import (
"fmt"
"log"
"net"
"net/http"
"os"
)
package main
import (
"fmt"
"runtime"
)
func main() {
fmt.Println("Hello, 世界!")
fmt.Println("GOOS:", runtime.GOOS)
FROM golang:1.11.1-alpine as build
RUN apk add --update --no-cache ca-certificates git
RUN mkdir /app
WORKDIR /app
COPY . .
RUN GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags="-w -s" -o /go/bin/app
FROM scratch
FROM golang:1.11.1-alpine as build
RUN apk add --update --no-cache ca-certificates git
RUN mkdir /app
WORKDIR /app
COPY . .
RUN GOOS=linux GOARCH=arm go build -a -installsuffix cgo -ldflags="-w -s" -o /go/bin/app
FROM scratch
{
"schemaVersion": 2,
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
"manifests": [
{
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"size": 737,
"digest": "sha256:c604e3508da0da4ba367c3a55dab35f8f45f71111e267b967e0a2680cd0e858a",
"platform": {
"architecture": "amd64",
{
"schemaVersion": 2,
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
"manifests": [
{
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"size": 737,
"digest": "sha256:c604e3508da0da4ba367c3a55dab35f8f45f71111e267b967e0a2680cd0e858a",
"platform": {
"architecture": "amd64",
@billglover
billglover / Dockerfile
Created November 19, 2019 14:23
A minimal Dockerfile for Go applications
FROM golang:alpine as build
RUN apk add --update --no-cache ca-certificates git
RUN adduser -D -g '' appuser
RUN mkdir /src
WORKDIR /src
COPY . .
RUN go mod download
@billglover
billglover / config.yaml
Created December 20, 2019 15:29
Get Clair up and running using Docker Compose
clair:
database:
type: pgsql
options:
source: host=clair_postgres port=5432 user=postgres sslmode=disable statement_timeout=60000
cachesize: 16384
maxopenconnections: 10
api:
addr: "0.0.0.0:6060"
healthaddr: "0.0.0.0:6061"
@billglover
billglover / set-kubeconfig.sh
Created June 10, 2020 19:02
Set the KUBECONFIG envar with all YAML files in the specified folder.
#!/bin/sh
DEFAULT_CONTEXTS="$HOME/.kube/config"
if test -f "${DEFAULT_CONTEXTS}"
then
export KUBECONFIG="$DEFAULT_CONTEXTS"
fi
CUSTOM_CONTEXTS="$HOME/.kube/custom-contexts"
mkdir -p "${CUSTOM_CONTEXTS}"
@billglover
billglover / main.go
Created June 17, 2020 18:57
Cross Compilation Demo
import (
"fmt"
"sync/atomic"
)
type T struct {
a byte
b int64
}