forked from taskcluster/taskcluster
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild-ci-image.sh
executable file
·63 lines (52 loc) · 2.19 KB
/
build-ci-image.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#! /bin/bash
repo_root=$(dirname "$0")/../..
node_version=$(jq -r .engines.node "${repo_root}/package.json")
if [ -z "${node_version}" ]; then
echo "Could not determine node version from top-level package.json"
exit 1
fi
go_version=$(<${repo_root}/.go-version)
go_version=${go_version#go}
if [ -z "${go_version}" ]; then
echo "Could not determine go version from top-level .go-version"
exit 1
fi
pg_version=11
tmpdir=$(mktemp -d)
trap "cd /; rm -rf ${tmpdir}" EXIT
cat > ${tmpdir}/pginstall <<EOF
#! /bin/bash
set -ex
# install postgres
apt-get update
apt-get install -y curl ca-certificates gnupg
curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" > /etc/apt/sources.list.d/pgdg.list
apt-get update
apt-get install -y postgresql-$pg_version
# add the en_US.UTF8 locale to the system
apt-get install -y --no-install-recommends locales
rm -rf /var/lib/apt/lists/*
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
# drop and re-create the default cluster with the appropriate locale
pg_dropcluster 11 main
pg_createcluster 11 main --lc-collate=en_US.UTF8 --lc-ctype=en_US.UTF8
# allow postgres to connect locally with no auth -- this is for testing!
echo 'local all all trust' > /etc/postgresql/$pg_version/main/pg_hba.conf
echo 'host all all 127.0.0.1/32 trust' >> /etc/postgresql/$pg_version/main/pg_hba.conf
echo 'host all all ::1/128 trust' >> /etc/postgresql/$pg_version/main/pg_hba.conf
EOF
cat > ${tmpdir}/Dockerfile <<EOF
FROM golang:${go_version}-stretch as golang
FROM node:${node_version}-stretch
COPY --from=golang /usr/local/go /usr/local/go
COPY --from=golang /go /go
ENV GOPATH /go
ENV PATH \$GOPATH/bin:/usr/local/go/bin:\$PATH
RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b \$GOPATH/bin v1.27.0
COPY pginstall /pginstall
RUN bash /pginstall && rm /pginstall
ENV TEST_DB_URL=postgresql://postgres@localhost/postgres
EOF
docker build -t "taskcluster/ci-image:node${node_version}-pg${pg_version}-go${go_version}" ${tmpdir}
[ -n "$DOCKER_PUSH" ] && docker push "taskcluster/ci-image:node${node_version}-pg${pg_version}-go${go_version}"