Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fearoffish/6e31ab544a8d92333fea0c4e297b701d to your computer and use it in GitHub Desktop.
Save fearoffish/6e31ab544a8d92333fea0c4e297b701d to your computer and use it in GitHub Desktop.
Okteto changes
# cli to build for multiple arches (example)
$ docker buildx build --platform linux/amd64,linux/386,linux/arm/v7 -t fearoffish/okteto:7 --push .
# devenv/bin/Dockerfile
FROM okteto/remote:0.2.5 AS remote
FROM okteto/supervisor:0.1.0 AS supervisor
FROM okteto/clean:0.1.0 AS clean
FROM alpine:latest as builder
# Os part of the target platform, for example: 'linux' or 'windows'
ARG TARGETOS
# Arch part of the target platform, for example 'amd64', 'arm64' or 'arm'
ARG TARGETARCH
RUN apk add --update \
curl \
&& rm -rf /var/cache/apk/*
# install syncthing
RUN curl -L "https://github.com/syncthing/syncthing/releases/download/v1.5.0/syncthing-${TARGETOS}-${TARGETARCH}-v1.5.0.tar.gz" -o /tmp/syncthing-${TARGETOS}-${TARGETARCH}-v1.5.0.tar.gz && \
tar -zxvf /tmp/syncthing-${TARGETOS}-${TARGETARCH}-v1.5.0.tar.gz -C /tmp && \
mv /tmp/syncthing-${TARGETOS}-${TARGETARCH}-v1.5.0/syncthing /usr/local/bin/syncthing && \
chmod +x /usr/local/bin/syncthing
# install kubectl
RUN curl -L "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/${TARGETOS}/${TARGETARCH}/kubectl" -o /usr/local/bin/kubectl
RUN chmod +x /usr/local/bin/kubectl
# install helm
RUN curl -L https://get.helm.sh/helm-v3.2.0-${TARGETOS}-${TARGETARCH}.tar.gz -o /tmp/helm.tar.gz
RUN tar -xvzf /tmp/helm.tar.gz -C /tmp
RUN mv /tmp/${TARGETOS}-${TARGETARCH}/helm /usr/local/bin/helm
RUN chmod +x /usr/local/bin/helm
# install okteto
RUN curl -fSL https://github.com/fearoffish/okteto/releases/download/1.8.6/okteto-${TARGETOS}-${TARGETARCH} -o /usr/local/bin/okteto
RUN chmod +x /usr/local/bin/okteto
# Test
RUN helm version
RUN kubectl version --client
RUN okteto version
FROM busybox as opensource
COPY --from=remote /usr/local/bin/remote /usr/local/bin/remote
COPY --from=supervisor /usr/local/bin/supervisor /usr/local/bin/supervisor
COPY --from=syncthing /bin/syncthing /usr/local/bin/syncthing
COPY --from=clean /usr/local/bin/clean /usr/local/bin/clean
# copy start
COPY bin/start.sh /usr/local/bin/start.sh
FROM opensource as cloud
COPY --from=builder /usr/local/bin/kubectl /usr/local/bin/kubectl
COPY --from=builder /usr/local/bin/okteto /usr/local/bin/okteto
COPY --from=builder /usr/local/bin/helm /usr/local/bin/helm
FROM alpine:3 as okteto
RUN apk add --no-cache ca-certificates
COPY --from=builder /usr/local/bin/kubectl /usr/local/bin/kubectl
COPY --from=builder /usr/local/bin/okteto /usr/local/bin/okteto
COPY --from=builder /usr/local/bin/helm /usr/local/bin/helm
# okteto/okteto Makefile
ifeq ($(strip $(VERSION_STRING)),)
VERSION_STRING := $(shell git rev-parse --short HEAD)
endif
BINDIR := $(CURDIR)/bin
PLATFORMS := linux/amd64/okteto-linux-x86_64 darwin/amd64/okteto-darwin-x86_64 windows/amd64/okteto.exe linux/arm64/okteto-linux-arm64 linux/arm/okteto-linux-arm
BUILDCOMMAND := go build -ldflags "-s -w -X github.com/okteto/okteto/pkg/config.VersionString=${VERSION_STRING}" -tags "osusergo netgo static_build"
temp = $(subst /, ,$@)
os = $(word 1, $(temp))
arch = $(word 2, $(temp))
label = $(word 3, $(temp))
UNAME := $(shell uname)
ifeq ($(UNAME), Darwin)
SHACOMMAND := shasum -a 256
else
SHACOMMAND := sha256sum
endif
.DEFAULT_GOAL := build
.PHONY: release
build-all: $(PLATFORMS)
$(PLATFORMS):
GOOS=$(os) GOARCH=$(arch) CGO_ENABLED=0 $(BUILDCOMMAND) -o "bin/$(label)"
$(SHACOMMAND) "bin/$(label)" > "bin/$(label).sha256"
.PHONY: latest
latest:
echo ${VERSION_STRING} > bin/latest
.PHONY: lint
lint:
golangci-lint run
.PHONY: test
test:
go test -coverprofile=coverage.txt -covermode=atomic ./...
.PHONY: integration
integration:
go test github.com/okteto/okteto/integration -tags=integration --count=1 -v
.PHONY: build
build:
$(BUILDCOMMAND) -o ${BINDIR}/okteto
.PHONY: dep
dep:
go mod tidy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment