Skip to content

Commit 65c386c

Browse files
Switch from alpine to debian
1 parent 4c1b608 commit 65c386c

4 files changed

Lines changed: 51 additions & 37 deletions

File tree

.github/workflows/run-tests.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ jobs:
1313
strategy:
1414
matrix:
1515
include:
16-
- base_image: "golang:1.20.14-alpine3.19"
17-
pg_package: "postgresql14"
18-
- base_image: "golang:1.20.14-alpine3.19"
19-
pg_package: "postgresql15"
20-
- base_image: "golang:1.20.14-alpine3.19"
21-
pg_package: "postgresql16"
22-
- base_image: "golang:1.22.10-alpine3.21"
23-
pg_package: "postgresql17"
16+
- go_version: "1.20"
17+
pg_version: "14"
18+
- go_version: "1.20"
19+
pg_version: "15"
20+
- go_version: "1.20"
21+
pg_version: "16"
22+
- go_version: "1.22"
23+
pg_version: "17"
2424
steps:
2525
- name: Checkout code
2626
uses: actions/checkout@v3
2727
- name: Build Docker image
28-
run: docker build -t pg-schema-diff-test-runner -f ./build/Dockerfile.test --build-arg BASE_IMAGE=${{ matrix.base_image }} --build-arg POSTGRES_PACKAGE=${{ matrix.pg_package }} .
28+
run: docker build -t pg-schema-diff-test-runner -f ./build/Dockerfile.test --build-arg GO_VERSION=${{ matrix.go_version }} --build-arg PG_VERSION=${{ matrix.pg_version }} .
2929
- name: Run tests
3030
run: docker run pg-schema-diff-test-runner

build/Dockerfile.codegen

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
FROM golang:1.20.14-alpine3.19
1+
FROM golang:1.20-bookworm
22

3-
RUN apk update && \
4-
apk add --no-cache \
5-
build-base \
6-
git \
7-
make
3+
RUN apt-get update && apt-get install -y --no-install-recommends \
4+
build-essential \
5+
git \
6+
make \
7+
&& rm -rf /var/lib/apt/lists/*
88

99
RUN go install -tags=nowasm github.com/kyleconroy/sqlc/cmd/sqlc@v1.18.0
1010
ENTRYPOINT make code_gen

build/Dockerfile.lint

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
# Use a newer version of go to appease #golangci-lint
2-
FROM golang:1.20.6-alpine3.18
1+
FROM golang:1.20-bookworm
2+
3+
RUN apt-get update && apt-get install -y --no-install-recommends \
4+
make \
5+
python3 \
6+
python3-pip \
7+
wget \
8+
&& rm -rf /var/lib/apt/lists/*
39

4-
RUN apk update && \
5-
apk add --no-cache \
6-
make \
7-
python3 \
8-
py3-pip
910
# Install golang-ci-lint
1011
RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.56.2
11-
# Install sqlfluff
12-
RUN pip install wheel # It complains if we attempt to install this in the same command as Cython
13-
RUN pip install "Cython<3.0" pyyaml --no-build-isolation # Fix for https://github.com/yaml/pyyaml/issues/601
14-
RUN pip install "sqlfluff==3.3.0"
12+
13+
# Install sqlfluff (use --break-system-packages for Debian 12+)
14+
RUN pip install --break-system-packages wheel
15+
RUN pip install --break-system-packages "Cython<3.0" pyyaml --no-build-isolation
16+
RUN pip install --break-system-packages "sqlfluff==3.3.0"
1517

1618
WORKDIR /pg-schema-diff
1719
COPY . .

build/Dockerfile.test

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
1-
ARG BASE_IMAGE=golang:1.20.14-alpine3.19
1+
ARG GO_VERSION=1.20
2+
FROM golang:${GO_VERSION}-bookworm
23

3-
FROM $BASE_IMAGE
4+
ARG PG_VERSION=14
45

5-
ARG POSTGRES_PACKAGE=postgresql14
6-
RUN apk update && \
7-
apk add --no-cache \
8-
build-base \
9-
make \
10-
$POSTGRES_PACKAGE \
11-
$POSTGRES_PACKAGE-contrib \
12-
$POSTGRES_PACKAGE-client
6+
# Install build dependencies and PostgreSQL from official apt repository
7+
RUN apt-get update && apt-get install -y --no-install-recommends \
8+
build-essential \
9+
make \
10+
gnupg \
11+
wget \
12+
ca-certificates \
13+
lsb-release \
14+
&& wget -qO - https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /usr/share/keyrings/pgdg.gpg \
15+
&& echo "deb [signed-by=/usr/share/keyrings/pgdg.gpg] http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
16+
&& apt-get update \
17+
&& apt-get install -y --no-install-recommends \
18+
postgresql-${PG_VERSION} \
19+
postgresql-contrib-${PG_VERSION} \
20+
postgresql-client-${PG_VERSION} \
21+
&& rm -rf /var/lib/apt/lists/*
22+
23+
# Add PostgreSQL bin directory to PATH (Debian installs to /usr/lib/postgresql/<version>/bin/)
24+
ENV PATH="/usr/lib/postgresql/${PG_VERSION}/bin:${PATH}"
1325

1426
WORKDIR /pg-schema-diff
1527

@@ -20,7 +32,7 @@ RUN go mod download
2032

2133
# Run all tests from non-root. This will also prevent Postgres from complaining when
2234
# we try to launch it within tests
23-
RUN adduser --disabled-password --gecos '' testrunner
35+
RUN useradd --create-home testrunner
2436
USER testrunner
2537

2638
# Run tests serially so logs can be streamed. Set overall timeout to 30m (the default is 10m, which is not enough)

0 commit comments

Comments
 (0)