trim dockerfiles, script to rebuild test images (#1403)
This commit is contained in:
parent
80772033ee
commit
b23a9153df
5 changed files with 68 additions and 26 deletions
|
@ -1,19 +1,16 @@
|
||||||
FROM ubuntu:latest
|
FROM ubuntu:22.04
|
||||||
|
|
||||||
ARG TAILSCALE_VERSION=*
|
ARG TAILSCALE_VERSION=*
|
||||||
ARG TAILSCALE_CHANNEL=stable
|
ARG TAILSCALE_CHANNEL=stable
|
||||||
|
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
&& apt-get install -y gnupg curl ssh \
|
&& apt-get install -y gnupg curl ssh dnsutils ca-certificates \
|
||||||
&& curl -fsSL https://pkgs.tailscale.com/${TAILSCALE_CHANNEL}/ubuntu/focal.gpg | apt-key add - \
|
&& adduser --shell=/bin/bash ssh-it-user
|
||||||
|
|
||||||
|
# Tailscale is deliberately split into a second stage so we can cash utils as a seperate layer.
|
||||||
|
RUN curl -fsSL https://pkgs.tailscale.com/${TAILSCALE_CHANNEL}/ubuntu/focal.gpg | apt-key add - \
|
||||||
&& curl -fsSL https://pkgs.tailscale.com/${TAILSCALE_CHANNEL}/ubuntu/focal.list | tee /etc/apt/sources.list.d/tailscale.list \
|
&& curl -fsSL https://pkgs.tailscale.com/${TAILSCALE_CHANNEL}/ubuntu/focal.list | tee /etc/apt/sources.list.d/tailscale.list \
|
||||||
&& apt-get update \
|
&& apt-get update \
|
||||||
&& apt-get install -y ca-certificates tailscale=${TAILSCALE_VERSION} dnsutils \
|
&& apt-get install -y tailscale=${TAILSCALE_VERSION} \
|
||||||
|
&& apt-get clean \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
RUN adduser --shell=/bin/bash ssh-it-user
|
|
||||||
|
|
||||||
ADD integration_test/etc_embedded_derp/tls/server.crt /usr/local/share/ca-certificates/
|
|
||||||
RUN chmod 644 /usr/local/share/ca-certificates/server.crt
|
|
||||||
|
|
||||||
RUN update-ca-certificates
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
FROM golang:latest
|
FROM golang:latest
|
||||||
|
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
&& apt-get install -y ca-certificates dnsutils git iptables ssh \
|
&& apt-get install -y dnsutils git iptables ssh ca-certificates \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
RUN useradd --shell=/bin/bash --create-home ssh-it-user
|
RUN useradd --shell=/bin/bash --create-home ssh-it-user
|
||||||
|
@ -10,15 +10,8 @@ RUN git clone https://github.com/tailscale/tailscale.git
|
||||||
|
|
||||||
WORKDIR /go/tailscale
|
WORKDIR /go/tailscale
|
||||||
|
|
||||||
RUN git checkout main
|
RUN git checkout main \
|
||||||
|
&& sh build_dist.sh tailscale.com/cmd/tailscale \
|
||||||
RUN sh build_dist.sh tailscale.com/cmd/tailscale
|
&& sh build_dist.sh tailscale.com/cmd/tailscaled \
|
||||||
RUN sh build_dist.sh tailscale.com/cmd/tailscaled
|
&& cp tailscale /usr/local/bin/ \
|
||||||
|
&& cp tailscaled /usr/local/bin/
|
||||||
RUN cp tailscale /usr/local/bin/
|
|
||||||
RUN cp tailscaled /usr/local/bin/
|
|
||||||
|
|
||||||
ADD integration_test/etc_embedded_derp/tls/server.crt /usr/local/share/ca-certificates/
|
|
||||||
RUN chmod 644 /usr/local/share/ca-certificates/server.crt
|
|
||||||
|
|
||||||
RUN update-ca-certificates
|
|
||||||
|
|
47
cmd/build-docker-img/main.go
Normal file
47
cmd/build-docker-img/main.go
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"github.com/juanfont/headscale/integration"
|
||||||
|
"github.com/juanfont/headscale/integration/tsic"
|
||||||
|
"github.com/ory/dockertest/v3"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
log.Printf("creating docker pool")
|
||||||
|
pool, err := dockertest.NewPool("")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("could not connect to docker: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("creating docker network")
|
||||||
|
network, err := pool.CreateNetwork("docker-integration-net")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("failed to create or get network: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, version := range integration.TailscaleVersions {
|
||||||
|
log.Printf("creating container image for Tailscale (%s)", version)
|
||||||
|
|
||||||
|
tsClient, err := tsic.New(
|
||||||
|
pool,
|
||||||
|
version,
|
||||||
|
network,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("failed to create tailscale node: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = tsClient.Shutdown()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("failed to shut down container: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
network.Close()
|
||||||
|
err = pool.RemoveNetwork(network)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("failed to remove network: %s", err)
|
||||||
|
}
|
||||||
|
}
|
|
@ -33,6 +33,7 @@ var (
|
||||||
tailscaleVersions2021 = []string{
|
tailscaleVersions2021 = []string{
|
||||||
"head",
|
"head",
|
||||||
"unstable",
|
"unstable",
|
||||||
|
"1.40.0",
|
||||||
"1.38.4",
|
"1.38.4",
|
||||||
"1.36.2",
|
"1.36.2",
|
||||||
"1.34.2",
|
"1.34.2",
|
||||||
|
@ -279,7 +280,7 @@ func (s *Scenario) CreateTailscaleNodesInUser(
|
||||||
|
|
||||||
headscale, err := s.Headscale()
|
headscale, err := s.Headscale()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create tailscale node: %w", err)
|
return fmt.Errorf("failed to create tailscale node (version: %s): %w", version, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cert := headscale.GetCert()
|
cert := headscale.GetCert()
|
||||||
|
|
|
@ -212,7 +212,11 @@ func New(
|
||||||
dockertestutil.DockerAllowNetworkAdministration,
|
dockertestutil.DockerAllowNetworkAdministration,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not start tailscale container: %w", err)
|
return nil, fmt.Errorf(
|
||||||
|
"could not start tailscale container (version: %s): %w",
|
||||||
|
version,
|
||||||
|
err,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
log.Printf("Created %s container\n", hostname)
|
log.Printf("Created %s container\n", hostname)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue