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

Commit

Permalink
further attempts at fixing docker builds
Browse files Browse the repository at this point in the history
  • Loading branch information
sumerman committed Dec 15, 2022
1 parent 70ad9d3 commit 8aa9710
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 23 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,18 @@ jobs:
cache-from: type=gha,scope=${{matrix.base}}-${{matrix.pgversion}}-${{matrix.tsversion}}
cache-to: type=gha,mode=max,scope=${{matrix.base}}-${{matrix.pgversion}}-${{matrix.tsversion}}

- name: Run end-to-end tests
run: cargo test -p e2e
env:
TS_DOCKER_IMAGE: ghcr.io/timescale/dev_promscale_extension:${{steps.metadata.outputs.image_branch_name}}-ts${{matrix.tsversion}}-pg${{matrix.pgversion}}${{steps.metadata.outputs.build_type_suffix}}
RUST_LOG: info

- name: Run SQL tests
run: cargo test -p sql-tests
env:
TS_DOCKER_IMAGE: ghcr.io/timescale/dev_promscale_extension:${{steps.metadata.outputs.image_branch_name}}-ts${{matrix.tsversion}}-pg${{matrix.pgversion}}${{steps.metadata.outputs.build_type_suffix}}
USE_DOCKER: true

- name: Run end-to-end tests
run: cargo test -p e2e
env:
TS_DOCKER_IMAGE: ghcr.io/timescale/dev_promscale_extension:${{steps.metadata.outputs.image_branch_name}}-ts${{matrix.tsversion}}-pg${{matrix.pgversion}}${{steps.metadata.outputs.build_type_suffix}}
RUST_LOG: info

- name: Check SQL Documentation
if: ${{ matrix.pgversion == 14 && matrix.base == 'ha' }}
env:
Expand Down
10 changes: 6 additions & 4 deletions alpine.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ ARG PG_VERSION=14
ARG PREVIOUS_IMAGE=timescaledev/promscale-extension:latest-ts2-pg${PG_VERSION}
FROM timescaledev/timescaledb:nightly-pg${PG_VERSION} as builder

LABEL maintainer="Timescale https://www.timescale.com"
ARG RUST_VERSION=1.64.0
ARG PG_VERSION

Expand All @@ -14,6 +15,7 @@ RUN \
gcc \
libgcc \
libc-dev \
clang-dev \
clang-libs \
make \
git \
Expand Down Expand Up @@ -113,19 +115,19 @@ RUN \
llvm

RUN \
git clone --branch v1.12 --depth 1 https://github.com/dimitri/pgextwlist.git /pgextwlist && \
git clone --branch v1.15 --depth 1 https://github.com/dimitri/pgextwlist.git /pgextwlist && \
cd /pgextwlist && \
make

FROM ${PREVIOUS_IMAGE} as prev_img
# FROM ${PREVIOUS_IMAGE} as prev_img

# COPY over the new files to the image. Done as a seperate stage so we don't
# ship the build tools.
FROM timescaledev/timescaledb:nightly-pg${PG_VERSION}
ARG PG_VERSION

COPY --from=prev_img /usr/local/lib/postgresql/promscale* /usr/local/lib/postgresql
COPY --from=prev_img /usr/local/share/postgresql/extension/promscale* /usr/local/share/postgresql/extension
# COPY --from=prev_img /usr/local/lib/postgresql/promscale* /usr/local/lib/postgresql
# COPY --from=prev_img /usr/local/share/postgresql/extension/promscale* /usr/local/share/postgresql/extension

COPY --from=builder /build/promscale/target/release/promscale-pg${PG_VERSION}/usr/local/lib/postgresql /usr/local/lib/postgresql
COPY --from=builder /build/promscale/target/release/promscale-pg${PG_VERSION}/usr/local/share/postgresql /usr/local/share/postgresql
Expand Down
40 changes: 28 additions & 12 deletions e2e/tests/upgrade-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,15 @@ fn test_upgrade(from_version: FromVersion, with_data: bool) {

// figure out which image we should start with in the upgrade process
// based on alpine vs ha and postgres version
let from_image_uri = from_image(&flavor, &pg_version, &from_version);
let from_image_uri = if let Some(img) = from_image(&flavor, &pg_version, &from_version) {
img
} else {
info!(
"from image is not defined for the selected flavor {} and PG version {}",
flavor, pg_version
);
return;
};
info!("from image {}", from_image_uri);
info!("to image {}", to_image_uri);

Expand Down Expand Up @@ -342,33 +350,41 @@ fn test_upgrade(from_version: FromVersion, with_data: bool) {
assert!(are_equal);
}

fn from_image(flavor: &Flavor, pg_version: &PgVersion, from_version: &FromVersion) -> String {
fn from_image(
flavor: &Flavor,
pg_version: &PgVersion,
from_version: &FromVersion,
) -> Option<String> {
match flavor {
Flavor::Alpine => match from_version {
// Our timescaledev images are deprecated, but they are the only option for an alpine
// image at the moment. They also are nicely tagged with the exact extension version.
FromVersion::First => format!(
FromVersion::First => Some(format!(
"timescaledev/promscale-extension:0.5.0-ts2.6.1-pg{}",
pg_version
),
FromVersion::Prior => format!(
))
.filter(|_| *pg_version != PgVersion::V15),
FromVersion::Prior => Some(format!(
"{}{}",
ALPINE_WITH_EXTENSION_LAST_RELEASED_PREFIX, pg_version
),
))
.filter(|_| *pg_version != PgVersion::V15),
},
Flavor::HA => match from_version {
// The timescaledb-ha docker images aren't tagged with the version of the promscale
// extension that they contain, so we need to keep a map of exact image tags (with
// patch version) for the first release (with extension 0.5.0) and the prior release.
FromVersion::First => match pg_version {
PgVersion::V14 => String::from("timescale/timescaledb-ha:pg14.2-ts2.6.1-p5"),
PgVersion::V13 => String::from("timescale/timescaledb-ha:pg13.6-ts2.6.1-p5"),
PgVersion::V12 => String::from("timescale/timescaledb-ha:pg12.10-ts2.6.1-p2"),
PgVersion::V15 => None,
PgVersion::V14 => Some(String::from("timescale/timescaledb-ha:pg14.2-ts2.6.1-p5")),
PgVersion::V13 => Some(String::from("timescale/timescaledb-ha:pg13.6-ts2.6.1-p5")),
PgVersion::V12 => Some(String::from("timescale/timescaledb-ha:pg12.10-ts2.6.1-p2")),
},
FromVersion::Prior => match pg_version {
PgVersion::V14 => String::from(HA_WITH_LAST_RELEASED_EXTENSION_PG14),
PgVersion::V13 => String::from(HA_WITH_LAST_RELEASED_EXTENSION_PG13),
PgVersion::V12 => String::from(HA_WITH_LAST_RELEASED_EXTENSION_PG12),
PgVersion::V15 => None,
PgVersion::V14 => Some(String::from(HA_WITH_LAST_RELEASED_EXTENSION_PG14)),
PgVersion::V13 => Some(String::from(HA_WITH_LAST_RELEASED_EXTENSION_PG13)),
PgVersion::V12 => Some(String::from(HA_WITH_LAST_RELEASED_EXTENSION_PG12)),
},
},
}
Expand Down
6 changes: 5 additions & 1 deletion test-common/src/postgres_container/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ pub enum ImageOrigin {
}

#[allow(dead_code)]
#[derive(Debug)]
#[derive(Debug, PartialEq, Eq)]
pub enum PgVersion {
V15,
V14,
V13,
V12,
Expand All @@ -34,6 +35,7 @@ impl TryFrom<&str> for PgVersion {

fn try_from(value: &str) -> Result<Self, Self::Error> {
match value {
"15" => Ok(PgVersion::V15),
"14" => Ok(PgVersion::V14),
"13" => Ok(PgVersion::V13),
"12" => Ok(PgVersion::V12),
Expand All @@ -45,6 +47,7 @@ impl TryFrom<&str> for PgVersion {
impl Display for PgVersion {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
PgVersion::V15 => write!(f, "15"),
PgVersion::V14 => write!(f, "14"),
PgVersion::V13 => write!(f, "13"),
PgVersion::V12 => write!(f, "12"),
Expand All @@ -62,6 +65,7 @@ pub fn postgres_image_uri(origin: ImageOrigin, version: PgVersion) -> String {
PgVersion::V12 => "pg12",
PgVersion::V13 => "pg13",
PgVersion::V14 => "pg14",
PgVersion::V15 => "pg15",
};
format!("{}{}", prefix, version)
}
Expand Down

0 comments on commit 8aa9710

Please sign in to comment.