From be9a580e6955931d806655c987da2bdb170b320c Mon Sep 17 00:00:00 2001 From: Nick Hudson Date: Mon, 5 Feb 2024 18:07:43 -0600 Subject: [PATCH] add new build for images --- .../find-changed-directories/action.yml | 53 ++++ .github/workflows/build_images.yaml | 116 ------- .github/workflows/build_tembo_pg_slim.yaml | 287 ++++++++++++++++++ dw-cnpg/Dockerfile | 5 +- ml-cnpg/Dockerfile | 5 +- standard-cnpg/Dockerfile | 7 +- tembo-pg-slim/Dockerfile | 13 +- 7 files changed, 362 insertions(+), 124 deletions(-) create mode 100644 .github/actions/find-changed-directories/action.yml delete mode 100644 .github/workflows/build_images.yaml create mode 100644 .github/workflows/build_tembo_pg_slim.yaml diff --git a/.github/actions/find-changed-directories/action.yml b/.github/actions/find-changed-directories/action.yml new file mode 100644 index 0000000..49b5452 --- /dev/null +++ b/.github/actions/find-changed-directories/action.yml @@ -0,0 +1,53 @@ +name: 'Find changed directories' +description: 'Finds directories containing a specific filename in the root of that directory, filtering out directories that are unchanged relative to a given branch name' +inputs: + contains_the_file: + description: 'Look for directories with this file in the root of that directory. For example, Dockerfile or Cargo.toml' + required: true + fetch_branch_to_compare: + description: 'The branch to fetch when looking to compare a ref, typically main' + default: "main" + required: true + changed_relative_to_ref: + description: 'The ref on the fetched branch to compare with to determine if this directory has changed. For example "origin/main" or a git commit hash.' + required: true + ignore_dirs: + description: A list of directories to ignore. + required: false + default: '' +outputs: + build_matrix: + description: "Input this output to your matrix build in a following job, like this 'fromJson(needs.find_directories.outputs.build_matrix)'" + value: ${{ steps.find_directories.outputs.build_matrix }} +runs: + using: "composite" + steps: + - name: Find directories with a given file name + shell: bash + id: find_directories + run: | + set -xe + git fetch origin ${{ inputs.fetch_branch_to_compare }} || true + # Get directories with a Dockerfile that have not changed + # relative to the branch we are pulling into + echo "${{inputs.ignore_dirs}}" + IFS=', ' read -r -a array <<< "${{inputs.ignore_dirs}}" + EXCLUDE_OPTS=() + for exclude_dir in "${array[@]}"; do + EXCLUDE_OPTS+=("-not" "-path" "*/$exclude_dir/*") + done + directories=$( + find . -name ${{ inputs.contains_the_file }} -not -path "*/target/*" -not -path "*/.github/*" "${EXCLUDE_OPTS[@]}" -exec dirname {} \; | while read dir; do + # This will check if the directory has changed relative to the branch we are PRing + # into, and if it's not a PR, in the case of main or release/**, then it will + # build all docker directories + if git diff --quiet HEAD ${{ inputs.changed_relative_to_ref }} -- "$dir"; then + echo "" + else + echo "$dir" + fi + done) + # Format directories into a build matrix + matrix_include=$(echo "${directories}" | awk 'NF{print $NF};' | while read dir; do dir_without_dot=$(basename ${dir}); echo "{\"path\": \"$dir\", \"name\": \"$dir_without_dot\"}"; done | jq -scM '{"include": .}') + echo "${matrix_include}" + echo "build_matrix=${matrix_include}" >> $GITHUB_OUTPUT diff --git a/.github/workflows/build_images.yaml b/.github/workflows/build_images.yaml deleted file mode 100644 index 124ea03..0000000 --- a/.github/workflows/build_images.yaml +++ /dev/null @@ -1,116 +0,0 @@ -name: Build and push images - -on: - pull_request: {} - push: - branches: - - 'main' - -jobs: - find_directories: - name: Find directories with Dockerfiles - runs-on: ubuntu-20.04 - outputs: - build_images: ${{ steps.append_pg_configs.outputs.build_matrix }} - short_sha: ${{ steps.versions.outputs.SHORT_SHA }} - branch_name: ${{ steps.versions.outputs.BRANCH_NAME }} - steps: - - name: Check out the repo - uses: actions/checkout@v3 - - name: Set version strings - id: versions - run: | - echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - echo "BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_OUTPUT - - name: Check out the tembo repo to reuse some actions - uses: actions/checkout@v3 - with: - repository: tembo-io/tembo - path: ./.tembo - ref: 737713f5839bcd3f533644fe316540d890c611a8 - - name: list dir - run: ls -la .tembo/.github/actions - - name: Find directories with Dockerfiles that changed - id: find_directories - uses: ./.tembo/.github/actions/find-changed-directories - with: - contains_the_file: Dockerfile - # If the branch does not exist, then it will not - # filter any directories containing the file. - # This allows for filtering out unchanged directories - # in a pull request, and using all directories on the release - # or main branches. - changed_relative_to_ref: origin/${{ github.base_ref || 'not-a-branch' }} - - name: Append PostgreSQL configurations to matrix - id: append_pg_configs - run: | - # Read the initial matrix from the output of a previous step - INITIAL_MATRIX="${{ toJson(steps.find_directories.outputs.build_matrix) }}" - echo "Initial Matrix: $INITIAL_MATRIX" - - # Define PostgreSQL configurations to append - PG_CONFIGS='[{"pg_release": "14.10", "pg_version": "14"}, {"pg_release": "15.3", "pg_version": "15"}, {"pg_release": "16.1", "pg_version": "16"}]' - - # Use jq to properly append the configurations, ensuring valid JSON format - # Note: This requires jq to be installed or available in the runner environment - MODIFIED_MATRIX=$(echo $INITIAL_MATRIX | jq -c --argjson pgConfigs "$PG_CONFIGS" '.include += $pgConfigs') - - echo "Modified Matrix: $MODIFIED_MATRIX" - - # Use the new syntax for setting outputs - echo "build_matrix=$MODIFIED_MATRIX" >> $GITHUB_OUTPUT - - - build_and_push: - name: Build and push images - permissions: - id-token: write - contents: read - runs-on: - - self-hosted - - dind - - large-8x8 - needs: - - find_directories - strategy: - fail-fast: false - matrix: ${{ fromJson(needs.find_directories.outputs.build_images) }} - outputs: - short_sha: ${{ steps.versions.outputs.SHORT_SHA }} - steps: - - name: Check out the repo - uses: actions/checkout@v3 - - name: Set version strings - id: versions - run: | - echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - - name: Determine which tags to publish - id: tags - run: | - BRANCH_NAME="${{ needs.find_directories.outputs.branch_name }}" - if [ "${BRANCH_NAME}" == "main" ]; then - echo "tag_latest=true" >> $GITHUB_OUTPUT - echo "tag_cargo=true" >> $GITHUB_OUTPUT - elif [[ "${BRANCH_NAME}" == release/* ]]; then - echo "tag_cargo=true" >> $GITHUB_OUTPUT - echo "tag_latest=false" >> $GITHUB_OUTPUT - else - echo "tag_latest=false" >> $GITHUB_OUTPUT - echo "tag_cargo=false" >> $GITHUB_OUTPUT - fi - - name: Build and upload image - uses: ./.github/actions/build-and-push-to-quay - with: - image_name: ${{ matrix.name }} - docker_directory: ${{ matrix.path }} - registry: "quay.io/tembo" - tag_cargo_version_if_present: ${{ steps.tags.outputs.tag_cargo }} - publish_latest: ${{ steps.tags.outputs.tag_latest }} - publish_calver: ${{ steps.tags_outputs.tag_latest }} - quay_user: ${{ secrets.QUAY_USER_TEMBO }} - quay_password: ${{ secrets.QUAY_PASSWORD_TEMBO }} - quay_user_tembo: ${{ secrets.QUAY_USER_TEMBO }} - quay_password_tembo: ${{ secrets.QUAY_PASSWORD_TEMBO }} - gha_iam_role: ${{ secrets.GHA_IAM_ROLE }} - ecr_registry: ${{ secrets.ECR_REGISTRY }} - pg_version: ${{ matrix.pg_version }} \ No newline at end of file diff --git a/.github/workflows/build_tembo_pg_slim.yaml b/.github/workflows/build_tembo_pg_slim.yaml new file mode 100644 index 0000000..82f959e --- /dev/null +++ b/.github/workflows/build_tembo_pg_slim.yaml @@ -0,0 +1,287 @@ +name: build-tembo-pg-slim + +on: + push: + branches: + - main + paths: + - 'tembo-pg-slim/**' + pull_request: + branches: + - main + paths: + - 'tembo-pg-slim/**' + +jobs: + pre-build: + runs-on: ubuntu-latest + outputs: + short_sha: ${{ steps.versions.outputs.SHORT_SHA }} + branch_name: ${{ steps.versions.outputs.BRANCH_NAME }} + build_matrix: ${{ steps.append_pg_configs.outputs.build_matrix }} + tags: ${{ steps.tags.outputs.tags }} + steps: + - name: Check out the repo + uses: actions/checkout@v4 + - name: Set version strings + id: versions + run: | + echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + echo "BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_OUTPUT + - name: Append PostgreSQL configurations to matrix + id: append_pg_configs + run: | + PG_CONFIGS='[{"pg_release": "14.10", "pg_version": "14"}, {"pg_release": "15.3", "pg_version": "15"}, {"pg_release": "16.1", "pg_version": "16"}]' + MODIFIED_MATRIX=$(echo $PG_CONFIGS | jq -c '{include: .}') + echo "build_matrix=$MODIFIED_MATRIX" >> $GITHUB_OUTPUT + - name: Determine which tags to publish + id: tags_list + run: | + BRANCH_NAME="${{ steps.versions.outputs.BRANCH_NAME }}" + if [ "${BRANCH_NAME}" == "main" ]; then + echo "tag_latest=true" >> $GITHUB_OUTPUT + echo "tag_cargo=true" >> $GITHUB_OUTPUT + elif [[ "${BRANCH_NAME}" == release/* ]]; then + echo "tag_cargo=true" >> $GITHUB_OUTPUT + echo "tag_latest=false" >> $GITHUB_OUTPUT + else + echo "tag_latest=false" >> $GITHUB_OUTPUT + echo "tag_cargo=false" >> $GITHUB_OUTPUT + fi + - name: Install TOML parser + run: | + set -xe + wget https://github.com/freshautomations/stoml/releases/download/v0.7.1/stoml_linux_amd64 + mv stoml_linux_amd64 stoml + chmod +x stoml + sudo mv stoml /usr/local/bin/ + - name: Create whitespace-separated tags list + id: tags + run: | + SHORT_SHA="${{ steps.versions.outputs.SHORT_SHA }}" + TAGS='' + if [ "${{ steps.tags_list.outputs.tag_cargo }}" == "true" ]; then + echo "Cargo file detected, adding to tags" + VERSION=$(stoml Cargo.toml package.version)-${SHORT_SHA} + TAGS="$TAGS $VERSION" + fi + if [ "${{ steps.tags_list.outputs.tag_latest }}" == "true" ]; then + TAGS="$TAGS latest" + fi + TAGS="$TAGS ${SHORT_SHA}" + echo "tags=$TAGS" >> $GITHUB_OUTPUT + - name: Debug outputs + run: | + echo "Short SHA: ${{ steps.versions.outputs.SHORT_SHA }}" + echo "Branch Name: ${{ steps.versions.outputs.BRANCH_NAME }}" + echo "Build Matrix: ${{ steps.append_pg_configs.outputs.build_matrix }}" + echo "Tags: ${{ steps.tags.outputs.tags }}" + + tembo-pg-slim-build: + needs: pre-build + permissions: + id-token: write + contents: read + runs-on: + - self-hosted + - dind + - large-8x8 + strategy: + fail-fast: false + matrix: ${{fromJson(needs.pre-build.outputs.build_matrix)}} + env: + CONTAINER_NAME: "tembo-pg-slim" + steps: + - uses: actions/checkout@v4 + - name: Build Docker images based on conditions + run: | + IMAGE_NAME=$CONTAINER_NAME:pg${{ matrix.pg_version }} + docker build ./$CONTAINER_NAME --build-arg PG_RELEASE=${{ matrix.pg_release }} --build-arg PG_VERSION=${{ matrix.pg_version }} -t $IMAGE_NAME + shell: bash + - name: Login to Tembo Quay + uses: docker/login-action@v2 + with: + registry: ${{ secrets.QUAY_REPOSITORY }} + username: ${{ secrets.QUAY_USER_TEMBO }} + password: ${{ secrets.QUAY_PASSWORD_TEMBO }} + - name: Push to Quay + shell: bash + run: | + set -xe + IMAGE_NAME=$CONTAINER_NAME:pg${{ matrix.pg_version }} + IFS=' ' read -ra TAG_ARRAY <<< "${{ needs.pre-build.outputs.tags }}" + for tag in "${TAG_ARRAY[@]}"; do + docker tag $IMAGE_NAME ${{ secrets.QUAY_REPOSITORY }}/$IMAGE_NAME-$tag + docker push ${{ secrets.QUAY_REPOSITORY }}/$IMAGE_NAME-$tag + done + + standard-cnpg-build: + needs: [pre-build, tembo-pg-slim-build] + permissions: + id-token: write + contents: read + runs-on: + - self-hosted + - dind + - large-8x8 + strategy: + fail-fast: false + matrix: ${{fromJson(needs.pre-build.outputs.build_matrix)}} + env: + CONTAINER_NAME: "standard-cnpg" + steps: + - uses: actions/checkout@v4 + - name: Build Docker images based on conditions + run: | + IMAGE_NAME=$CONTAINER_NAME:pg${{ matrix.pg_version }} + docker build ./$CONTAINER_NAME --build-arg PG_RELEASE=${{ matrix.pg_release }} --build-arg PG_VERSION=${{ matrix.pg_version }} --build-arg TAG=${{ needs.pre-build.outputs.short_sha }} -t $IMAGE_NAME + shell: bash + - name: Login to Tembo Quay + uses: docker/login-action@v2 + with: + registry: ${{ secrets.QUAY_REPOSITORY }} + username: ${{ secrets.QUAY_USER_TEMBO }} + password: ${{ secrets.QUAY_PASSWORD_TEMBO }} + - name: Push to Quay + shell: bash + run: | + set -xe + IMAGE_NAME=$CONTAINER_NAME:pg${{ matrix.pg_version }} + IFS=' ' read -ra TAG_ARRAY <<< "${{ needs.pre-build.outputs.tags }}" + for tag in "${TAG_ARRAY[@]}"; do + docker tag $IMAGE_NAME ${{ secrets.QUAY_REPOSITORY }}/$IMAGE_NAME-$tag + docker push ${{ secrets.QUAY_REPOSITORY }}/$IMAGE_NAME-$tag + done + - name: Configure AWS credentials for ECR + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.GHA_IAM_ROLE }} + role-session-name: images-gha-docker-build-and-push + aws-region: "us-east-1" + - name: Install awscli + uses: unfor19/install-aws-cli-action@v1 + - name: Push to ECR + shell: bash + run: | + set -xe + IMAGE_NAME=$CONTAINER_NAME:pg${{ matrix.pg_version }} + IFS=' ' read -ra TAG_ARRAY <<< "${{ needs.pre-build.outputs.tags }}" + for tag in "${TAG_ARRAY[@]}"; do + aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${{ secrets.ECR_REGISTRY }}/$CONTAINER_NAME + docker tag $IMAGE_NAME ${{ secrets.ECR_REGISTRY }}/$IMAGE_NAME-$tag + docker push ${{ secrets.ECR_REGISTRY }}/$IMAGE_NAME-$tag + done + + ml-cnpg-build: + needs: [pre-build, standard-cnpg-build] + permissions: + id-token: write + contents: read + runs-on: + - self-hosted + - dind + - large-8x8 + strategy: + fail-fast: false + matrix: ${{fromJson(needs.pre-build.outputs.build_matrix)}} + env: + CONTAINER_NAME: "ml-cnpg" + steps: + - uses: actions/checkout@v4 + - name: Build Docker images based on conditions + run: | + IMAGE_NAME=$CONTAINER_NAME:pg${{ matrix.pg_version }} + docker build ./$CONTAINER_NAME --build-arg PG_RELEASE=${{ matrix.pg_release }} --build-arg PG_VERSION=${{ matrix.pg_version }} --build-arg TAG=${{ needs.pre-build.outputs.short_sha }} -t $IMAGE_NAME + shell: bash + - name: Login to Tembo Quay + uses: docker/login-action@v2 + with: + registry: ${{ secrets.QUAY_REPOSITORY }} + username: ${{ secrets.QUAY_USER_TEMBO }} + password: ${{ secrets.QUAY_PASSWORD_TEMBO }} + - name: Push to Quay + shell: bash + run: | + set -xe + IMAGE_NAME=$CONTAINER_NAME:pg${{ matrix.pg_version }} + IFS=' ' read -ra TAG_ARRAY <<< "${{ needs.pre-build.outputs.tags }}" + for tag in "${TAG_ARRAY[@]}"; do + docker tag $IMAGE_NAME ${{ secrets.QUAY_REPOSITORY }}/$IMAGE_NAME-$tag + docker push ${{ secrets.QUAY_REPOSITORY }}/$IMAGE_NAME-$tag + done + - name: Configure AWS credentials for ECR + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.GHA_IAM_ROLE }} + role-session-name: images-gha-docker-build-and-push + aws-region: "us-east-1" + - name: Install awscli + uses: unfor19/install-aws-cli-action@v1 + - name: Push to ECR + shell: bash + run: | + set -xe + IMAGE_NAME=$CONTAINER_NAME:pg${{ matrix.pg_version }} + IFS=' ' read -ra TAG_ARRAY <<< "${{ needs.pre-build.outputs.tags }}" + for tag in "${TAG_ARRAY[@]}"; do + aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${{ secrets.ECR_REGISTRY }}/$CONTAINER_NAME + docker tag $IMAGE_NAME ${{ secrets.ECR_REGISTRY }}/$IMAGE_NAME-$tag + docker push ${{ secrets.ECR_REGISTRY }}/$IMAGE_NAME-$tag + done + + dw-cnpg-build: + needs: [pre-build, standard-cnpg-build] + permissions: + id-token: write + contents: read + runs-on: + - self-hosted + - dind + - large-8x8 + strategy: + fail-fast: false + matrix: ${{fromJson(needs.pre-build.outputs.build_matrix)}} + env: + CONTAINER_NAME: "dw-cnpg" + steps: + - uses: actions/checkout@v4 + - name: Build Docker images based on conditions + run: | + IMAGE_NAME=$CONTAINER_NAME:pg${{ matrix.pg_version }} + docker build ./$CONTAINER_NAME --build-arg PG_RELEASE=${{ matrix.pg_release }} --build-arg PG_VERSION=${{ matrix.pg_version }} --build-arg TAG=${{ needs.pre-build.outputs.short_sha }} -t $IMAGE_NAME + shell: bash + - name: Login to Tembo Quay + uses: docker/login-action@v2 + with: + registry: ${{ secrets.QUAY_REPOSITORY }} + username: ${{ secrets.QUAY_USER_TEMBO }} + password: ${{ secrets.QUAY_PASSWORD_TEMBO }} + - name: Push to Quay + shell: bash + run: | + set -xe + IMAGE_NAME=$CONTAINER_NAME:pg${{ matrix.pg_version }} + IFS=' ' read -ra TAG_ARRAY <<< "${{ needs.pre-build.outputs.tags }}" + for tag in "${TAG_ARRAY[@]}"; do + docker tag $IMAGE_NAME ${{ secrets.QUAY_REPOSITORY }}/$IMAGE_NAME-$tag + docker push ${{ secrets.QUAY_REPOSITORY }}/$IMAGE_NAME-$tag + done + - name: Configure AWS credentials for ECR + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.GHA_IAM_ROLE }} + role-session-name: images-gha-docker-build-and-push + aws-region: "us-east-1" + - name: Install awscli + uses: unfor19/install-aws-cli-action@v1 + - name: Push to ECR + shell: bash + run: | + set -xe + IMAGE_NAME=$CONTAINER_NAME:pg${{ matrix.pg_version }} + IFS=' ' read -ra TAG_ARRAY <<< "${{ needs.pre-build.outputs.tags }}" + for tag in "${TAG_ARRAY[@]}"; do + aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${{ secrets.ECR_REGISTRY }}/$CONTAINER_NAME + docker tag $IMAGE_NAME ${{ secrets.ECR_REGISTRY }}/$IMAGE_NAME-$tag + docker push ${{ secrets.ECR_REGISTRY }}/$IMAGE_NAME-$tag + done diff --git a/dw-cnpg/Dockerfile b/dw-cnpg/Dockerfile index 6646c0d..b66c751 100644 --- a/dw-cnpg/Dockerfile +++ b/dw-cnpg/Dockerfile @@ -1,4 +1,7 @@ -FROM quay.io/tembo/standard-cnpg:15.3.0-1-795fc99 +ARG PG_VERSION=15 +ARG TAG=latest + +FROM quay.io/tembo/standard-cnpg:pg${PG_VERSION}-${TAG} USER root WORKDIR / diff --git a/ml-cnpg/Dockerfile b/ml-cnpg/Dockerfile index d1b3f79..a0a83b8 100644 --- a/ml-cnpg/Dockerfile +++ b/ml-cnpg/Dockerfile @@ -1,4 +1,7 @@ -FROM quay.io/tembo/standard-cnpg:15.3.0-1-795fc99 +ARG PG_VERSION=15 +ARG TAG=latest + +FROM quay.io/tembo/standard-cnpg:pg${PG_VERSION}-${TAG} USER root ARG PGML_VERSION=2.7.1 diff --git a/standard-cnpg/Dockerfile b/standard-cnpg/Dockerfile index bfec160..01650e3 100644 --- a/standard-cnpg/Dockerfile +++ b/standard-cnpg/Dockerfile @@ -1,4 +1,5 @@ ARG PG_VERSION=15 +ARG TAG=latest FROM rust:1.70-bookworm as builder @@ -7,7 +8,7 @@ ARG TRUNK_VER=0.12.19 ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL sparse RUN cargo install --version $TRUNK_VER pg-trunk -FROM quay.io/tembo/tembo-pg-slim:pg${PG_VERSION} +FROM quay.io/tembo/tembo-pg-slim:pg${PG_VERSION}-${TAG} USER root @@ -79,10 +80,10 @@ RUN set -xe; \ rm -rf /var/lib/apt/lists/*; # Install pg_stat_statements -RUN trunk install pg_stat_statements +RUN /usr/bin/trunk install pg_stat_statements # Install auto_explain -RUN trunk install auto_explain +RUN /usr/bin/trunk install auto_explain # cache pg_stat_statements and auto_explain and pg_stat_kcache to temp directory RUN set -eux; \ diff --git a/tembo-pg-slim/Dockerfile b/tembo-pg-slim/Dockerfile index 315a71c..c493e1a 100644 --- a/tembo-pg-slim/Dockerfile +++ b/tembo-pg-slim/Dockerfile @@ -9,6 +9,11 @@ ARG PG_RELEASE 15.3 ARG PG_VERSION 15 ENV PATH $PATH:/usr/lib/postgresql/$PG_VERSION/bin +# Get latest package updates +RUN set -eux; \ + apt-get update; \ + apt-get upgrade -y + # Set the postgres user's permissions RUN set -eux; \ groupadd -r postgres --gid=999; \ @@ -68,9 +73,9 @@ RUN set -eux; \ WORKDIR postgresql-${PG_RELEASE} ENV CFLAGS "-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer" ENV LDFLAGS "-Wl,-z,relro -Wl,-z,now" -RUN ./configure --prefix=/usr/lib/postgresql/${PG_MAJOR} \ +RUN ./configure --prefix=/usr/lib/postgresql/${PG_VERSION} \ --datarootdir=${ALTDIR} \ - --libdir=${ALTDIR}/${PG_MAJOR}/lib \ + --libdir=${ALTDIR}/${PG_VERSION}/lib \ --with-perl \ --with-python \ --with-tcl \ @@ -98,12 +103,14 @@ RUN make -j$(nproc) RUN make install RUN cd .. && rm postgresql-${PG_RELEASE}.tar.bz2 +WORKDIR / +RUN rm -rf /postgresql-${PG_RELEASE} + # Remove pre-installed pg_config RUN rm /usr/bin/pg_config RUN mkdir -p /var/run/postgresql && chmod 775 /var/run/postgresql RUN mkdir -p /usr/share/postgresql/${PG_MAJOR}/extension && chmod 775 /usr/share/postgresql/${PG_MAJOR}/extension - USER postgres CMD ["postgres"]