Skip to content

Commit

Permalink
Merge pull request #86 from antoniomika/v1.0-work
Browse files Browse the repository at this point in the history
Started work on migrating to cobra and viper
  • Loading branch information
antoniomika authored May 30, 2020
2 parents 61fb30a + 6a3eedf commit da08f8a
Show file tree
Hide file tree
Showing 39 changed files with 3,722 additions and 1,922 deletions.
10 changes: 9 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/.dockerignore
/Dockerfile
/Dockerfile.buildkit
/.git/
/keys/
/.github/
/.gitignore
/deploy/
!/deploy/pubkeys/.gitkeep
/dist/
/sish
/.vscode/
8 changes: 6 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- uses: actions/checkout@v1
- name: Lint the codebase
run: |
docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.21.0 golangci-lint run -E goimports
docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.27.0 golangci-lint run -E goimports
- name: Set up Docker Buildx
uses: crazy-max/ghaction-docker-buildx@v1
with:
Expand All @@ -29,7 +29,10 @@ jobs:
if [[ ${GITHUB_REF} =~ ^refs\/tags\/v.*$ ]]
then
REF="${GITHUB_REF//refs\/tags\/}"
OTHER_TAGS="${OTHER_TAGS} -t ${GITHUB_REPOSITORY}:latest"
if ! [[ ${GITHUB_REF} =~ ^refs\/tags\/v.*-.*$ ]]
then
OTHER_TAGS="${OTHER_TAGS} -t ${GITHUB_REPOSITORY}:latest"
fi
fi
docker buildx build \
Expand All @@ -42,4 +45,5 @@ jobs:
--build-arg DATE=${DATE} \
-t ${GITHUB_REPOSITORY}:${GITHUB_SHA} \
-t ${GITHUB_REPOSITORY}:${REF} \
-f Dockerfile.buildkit \
${OTHER_TAGS} .
9 changes: 2 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,12 @@ jobs:
- uses: actions/checkout@v1
- name: Lint the codebase
run: |
docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.21.0 golangci-lint run -E goimports
- name: Set up Docker Buildx
uses: crazy-max/ghaction-docker-buildx@v1
with:
version: latest
docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.27.0 golangci-lint run -E goimports
- name: Build and the Docker images
run: |
DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
docker buildx build \
--platform linux/arm/v7,linux/arm64,linux/amd64 \
docker build \
--cache-from ${GITHUB_REPOSITORY}-cache \
--build-arg VERSION=${GITHUB_SHA} \
--build-arg COMMIT=${GITHUB_SHA} \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.13
go-version: 1.14
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v1
with:
Expand Down
11 changes: 2 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
keys/*
!keys/.gitkeep
pubkeys/*
!pubkeys/.gitkeep
ssl/*
!ssl/.gitkeep
sish
deploy/*
!deploy/docker-compose.yml
deploy/
dist/
sish
__debug_bin
8 changes: 5 additions & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ before:
- go mod tidy
- go generate ./...
builds:
- env:
- CGO_ENABLED=0
- ldflags:
- -s -w -X github.com/antoniomika/sish/cmd.Version={{ .Version }} -X github.com/antoniomika/sish/cmd.Commit={{ .Commit }} -X github.com/antoniomika/sish/cmd.Date={{ .Date }}
env:
- CGO_ENABLED=0
goos:
- linux
- win
Expand All @@ -31,5 +33,5 @@ archives:
files:
- LICENSE*
- README*
- pubkeys/
- deploy/pubkeys/
- templates/**/*
32 changes: 18 additions & 14 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,24 @@
"program": "${workspaceFolder}",
"env": {},
"args": [
"-sish.auth=false",
"-sish.debug=true",
"-sish.subdomainlen=3",
"-sish.httpsenabled=false",
"-sish.http=localhost:8081",
"-sish.addr=localhost:2222",
"-sish.domain=testing.ssi.sh",
"-sish.forcerandomsubdomain=false",
"-sish.bindrandom=false",
"-sish.tcpalias=true",
"-sish.proxyprotoenabled=false",
"-sish.logtoclient=true",
"-sish.adminenabled=true",
"-sish.serviceconsoleenabled=true"
"--debug=true",
"--bind-random-subdomains-length=3",
"--http-address=:8081",
"--ssh-address=:2222",
"--domain=testing.ssi.sh",
"--bind-random-subdomains=false",
"--bind-random-ports=false",
"--https=false",
"--authentication=false",
"--tcp-aliases=true",
"--proxy-protocol=false",
"--log-to-client=true",
"--admin-console=true",
"--service-console=true",
"--verify-ssl=false",
"--http-load-balancer=true",
"--tcp-load-balancer=true",
"--alias-load-balancer=true"
]
}
]
Expand Down
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM golang:1.13.2-alpine as builder
FROM golang:1.14-alpine as builder
LABEL maintainer="Antonio Mika <me@antoniomika.me>"

ENV GOCACHE /gocache
ENV CGO_ENABLED 0

WORKDIR /app

RUN apk add --no-cache git
RUN apk add --no-cache git ca-certificates

COPY go.mod .
COPY go.sum .
Expand All @@ -19,7 +19,7 @@ ARG VERSION=dev
ARG COMMIT=none
ARG DATE=unknown

RUN go install -ldflags="-s -w -X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}"
RUN go install -ldflags="-s -w -X github.com/antoniomika/sish/cmd.Version=${VERSION} -X github.com/antoniomika/sish/cmd.Commit=${COMMIT} -X github.com/antoniomika/sish/cmd.Date=${DATE}"
RUN go test -i ./...

FROM scratch
Expand All @@ -28,7 +28,8 @@ LABEL maintainer="Antonio Mika <me@antoniomika.me>"
WORKDIR /app

COPY --from=builder /tmp /tmp
COPY --from=builder /app/pubkeys /app/pubkeys
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /app/deploy/pubkeys /app/deploy/pubkeys
COPY --from=builder /app/templates /app/templates
COPY --from=builder /go/bin/sish /app/sish

Expand Down
40 changes: 40 additions & 0 deletions Dockerfile.buildkit
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM --platform=$BUILDPLATFORM golang:1.14-alpine as builder
LABEL maintainer="Antonio Mika <me@antoniomika.me>"

ENV GOCACHE /gocache
ENV CGO_ENABLED 0

WORKDIR /app

RUN apk add --no-cache git ca-certificates

COPY go.mod .
COPY go.sum .

RUN go mod download

COPY . .

ARG VERSION=dev
ARG COMMIT=none
ARG DATE=unknown

ARG TARGETOS
ARG TARGETARCH

ENV GOOS=${TARGETOS} GOARCH=${TARGETARCH}

RUN go build -o /go/bin/sish -ldflags="-s -w -X github.com/antoniomika/sish/cmd.Version=${VERSION} -X github.com/antoniomika/sish/cmd.Commit=${COMMIT} -X github.com/antoniomika/sish/cmd.Date=${DATE}"

FROM scratch as release
LABEL maintainer="Antonio Mika <me@antoniomika.me>"

WORKDIR /app

COPY --from=builder /tmp /tmp
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /app/deploy/pubkeys /app/deploy/pubkeys
COPY --from=builder /app/templates /app/templates
COPY --from=builder /go/bin/sish /app/sish

ENTRYPOINT ["/app/sish"]
Loading

0 comments on commit da08f8a

Please sign in to comment.