Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #926 from github/dockerfile-packaging-glibc
Browse files Browse the repository at this point in the history
Dockerfile packaging: glibc
  • Loading branch information
Shlomi Noach authored Jul 7, 2019
2 parents 917d422 + 959bcbb commit 34c8ac9
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 40 deletions.
32 changes: 11 additions & 21 deletions Dockerfile.packaging
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,21 @@
# ORC_USER (default: orc_server_user): username used to login to orchestrator backend MySQL server
# ORC_PASSWORD (default: orc_server_password): password used to login to orchestrator backend MySQL server

FROM alpine:3.10
FROM golang:1.12.6

RUN apk update
RUN apk upgrade
RUN apk add --update ruby
RUN apk add --update ruby-dev
RUN apk add --update gcc
RUN apk add --update libffi-dev
RUN apk add --update make
RUN apk add --update libc-dev
RUN apk add --update rpm
RUN apt-get update
RUN apt-get install -y ruby ruby-dev rubygems build-essential
RUN gem install --no-ri --no-rdoc fpm

ENV GOPATH=/tmp/go

RUN apk add --update libcurl
RUN apk add --update rsync
RUN apk add --update gcc
RUN apk add --update g++
RUN apk add --update build-base
RUN apk add --update bash
RUN apk add --update git
RUN apk add --update go
RUN apk add --update ruby-etc
RUN apk add --update tar
RUN apt-get install -y curl
RUN apt-get install -y rsync
RUN apt-get install -y gcc
RUN apt-get install -y g++
RUN apt-get install -y bash
RUN apt-get install -y git
RUN apt-get install -y tar
RUN apt-get install -y rpm

RUN mkdir -p $GOPATH/src/github.com/github/orchestrator
WORKDIR $GOPATH/src/github.com/github/orchestrator
Expand Down
51 changes: 44 additions & 7 deletions go/inst/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ func resolveHostname(hostname string) (string, error) {
return hostname, nil
case "cname":
return GetCNAME(hostname)
case "ip":
return getHostnameIP(hostname)
}
return hostname, nil
}
Expand Down Expand Up @@ -276,14 +278,49 @@ func RegisterHostnameUnresolve(registration *HostnameRegistration) (err error) {
return WriteHostnameUnresolve(&registration.Key, registration.Hostname)
}

func ResolveHostnameIPs(hostname string) error {
if _, found := hostnameIPsCache.Get(hostname); found {
return nil
func extractIPs(ips []net.IP) (ipv4String string, ipv6String string) {
for _, ip := range ips {
if ip4 := ip.To4(); ip4 != nil {
ipv4String = ip.String()
} else {
ipv6String = ip.String()
}
}
return ipv4String, ipv6String
}

func getHostnameIPs(hostname string) (ips []net.IP, fromCache bool, err error) {
if ips, found := hostnameIPsCache.Get(hostname); found {
return ips.([]net.IP), true, nil
}
ips, err = net.LookupIP(hostname)
if err != nil {
return ips, false, log.Errore(err)
}
ips, err := net.LookupIP(hostname)
hostnameIPsCache.Set(hostname, ips, cache.DefaultExpiration)
return ips, false, nil
}

func getHostnameIP(hostname string) (ipString string, err error) {
ips, _, err := getHostnameIPs(hostname)
if err != nil {
return log.Errore(err)
return ipString, err
}
ipv4String, ipv6String := extractIPs(ips)
if ipv4String != "" {
return ipv4String, nil
}
return ipv6String, nil
}

func ResolveHostnameIPs(hostname string) error {
ips, fromCache, err := getHostnameIPs(hostname)
if err != nil {
return err
}
if fromCache {
return nil
}
hostnameIPsCache.Set(hostname, true, cache.DefaultExpiration)
return writeHostnameIPs(hostname, ips)
ipv4String, ipv6String := extractIPs(ips)
return writeHostnameIPs(hostname, ipv4String, ipv6String)
}
13 changes: 1 addition & 12 deletions go/inst/resolve_dao.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
package inst

import (
"net"

"github.com/github/orchestrator/go/config"
"github.com/github/orchestrator/go/db"
"github.com/openark/golib/log"
Expand Down Expand Up @@ -327,16 +325,7 @@ func deleteHostnameResolves() error {
}

// writeHostnameIPs stroes an ipv4 and ipv6 associated witha hostname, if available
func writeHostnameIPs(hostname string, ips []net.IP) error {
ipv4String := ""
ipv6String := ""
for _, ip := range ips {
if ip4 := ip.To4(); ip4 != nil {
ipv4String = ip.String()
} else {
ipv6String = ip.String()
}
}
func writeHostnameIPs(hostname string, ipv4String string, ipv6String string) error {
writeFunc := func() error {
_, err := db.ExecOrchestrator(`
insert into
Expand Down

0 comments on commit 34c8ac9

Please sign in to comment.