Skip to content

Commit

Permalink
cmd/gomoteserver: add files to build gomote server
Browse files Browse the repository at this point in the history
This change adds files to build the gomote server. There
is a small fix on a flag description in the actual gomote
server itself.

Updates golang/go#61912
For golang/go#61772

Change-Id: If424342975bf210cd27d8b18879210eac53ea8fb
Reviewed-on: https://go-review.googlesource.com/c/build/+/520239
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Dmitri Shuralyov <[email protected]>
Run-TryBot: Carlos Amedee <[email protected]>
Reviewed-by: Dmitri Shuralyov <[email protected]>
Auto-Submit: Carlos Amedee <[email protected]>
  • Loading branch information
cagedmantis authored and gopherbot committed Aug 17, 2023
1 parent 82802b7 commit 1e72cea
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 2 deletions.
54 changes: 54 additions & 0 deletions cmd/gomoteserver/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright 2023 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

FROM golang:1.20-bookworm AS build
LABEL maintainer="[email protected]"

COPY go.mod /go/src/golang.org/x/build/go.mod
COPY go.sum /go/src/golang.org/x/build/go.sum

WORKDIR /go/src/golang.org/x/build

# Download module dependencies to improve speed of re-building the
# Docker image during minor code changes.
RUN go mod download

# Makefile passes a string with --build-arg version
# This becomes part of the cache key for all subsequent instructions,
# so it must not be placed above the "go mod download" command above.
ARG version=unknown

COPY . /go/src/golang.org/x/build/

RUN go install -ldflags "-X 'main.Version=$version'" golang.org/x/build/cmd/gomoteserver

FROM debian:bookworm AS build_drawterm

RUN apt-get update && apt-get install -y --no-install-recommends \
git-core ca-certificates make gcc libc6-dev libx11-dev

# drawterm connects to plan9 instances like:
# echo glenda123 | ./drawterm -a <addr> -c <addr> -u glenda -k user=glenda
# Where <addr> is the IP address of the Plan 9 instance on GCE,
# "glenda" is the username and "glenda123" is the password.
RUN git clone https://github.com/0intro/conterm /tmp/conterm && \
cd /tmp/conterm && \
CONF=unix make && mv /tmp/conterm/drawterm /usr/local/bin && \
rm -rf /tmp/conterm

FROM debian:bookworm

# openssh client is for the gomote ssh proxy client.
# telnet is for the gomote ssh proxy to windows. (no ssh server there)
RUN apt-get update && apt-get install -y \
--no-install-recommends \
ca-certificates \
openssh-client \
telnet \
&& rm -rf /var/lib/apt/lists/*

COPY --from=build /go/bin/gomoteserver /
COPY --from=build_drawterm /usr/local/bin/drawterm /usr/local/bin/

ENTRYPOINT ["/gomoteserver"]
4 changes: 2 additions & 2 deletions cmd/gomoteserver/gomoteserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ func main() {
if err := secret.InitFlagSupport(context.Background()); err != nil {
log.Fatalln(err)
}
privateKey := secret.Flag(secret.NameGomoteSSHPrivateKey, "SendGrid API key for workflows involving sending email.")
publicKey := secret.Flag(secret.NameGomoteSSHPublicKey, "SendGrid API key for workflows involving sending email.")
privateKey := secret.Flag(secret.NameGomoteSSHPrivateKey, "Gomote SSH private key.")
publicKey := secret.Flag(secret.NameGomoteSSHPublicKey, "Gomote SSH public key.")

sp := remote.NewSessionPool(context.Background())
sshCA := mustRetrieveSSHCertificateAuthority()
Expand Down
16 changes: 16 additions & 0 deletions cmd/gomoteserver/version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

# Copyright 2023 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

VERSION=$(git rev-parse HEAD)
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if ! git diff-index HEAD --quiet || ! git diff-files --quiet; then
VERSION=$VERSION-dirty
dirty=1
fi
if [ -n "$dirty" ] || [ -z "$(git config --get-all "branch.${CURRENT_BRANCH}.remote")" ] || [ -n "$(git rev-list '@{upstream}..HEAD')" ]; then
VERSION=$VERSION-$USER-$(git show --quiet --pretty=%cI HEAD | perl -npe 's/[^\dT]//g;$_=substr($_,0,15)')
fi
echo "$VERSION"

0 comments on commit 1e72cea

Please sign in to comment.