Skip to content

Commit

Permalink
Build
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisBellew committed May 26, 2024
1 parent d177a36 commit 177eab4
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 13 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,22 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Cache Docker layers
id: docker-cache
uses: actions/cache@v3
with:
path: /tmp/docker_cache_*
key: postgres

# - name: Log in to Docker Hub
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}

- name: Run Postgres build script
run: ./build-postgres.sh
run: ./ci-build-postgres.sh ${{ steps.docker-cache.outputs.cache-hit }}

# - name: Build Postgres debug image
# uses: docker/build-push-action@v4
# with:
Expand Down
5 changes: 0 additions & 5 deletions build-postgres.sh

This file was deleted.

45 changes: 45 additions & 0 deletions ci-build-postgres.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash
set -e

cd postgres
./build.sh

#!/bin/bash

# Load the cache key from an environment variable
CACHE_KEY=$1

# Ensure the Docker buildx builder is set up
docker buildx create --use --name mybuilder

# Load the cache from the GitHub Actions cache
docker load -i /tmp/docker_cache_$CACHE_KEY.tar || true

#cd postgres
#./build.sh


# Set variables
CONTAINER_NAME="postgres_builder"
IMAGE_NAME="postgres-builder:latest"

# # Check if the container is already running
# if [ "$(docker ps -q -f name=$CONTAINER_NAME)" ]; then
# echo "Stopping and removing existing container $CONTAINER_NAME..."
# #docker stop $CONTAINER_NAME
# docker rm $CONTAINER_NAME --force
# fi

# Build the preparation Docker image
docker build -t $IMAGE_NAME ./postgres

# Run the container with Docker socket
docker run --name $CONTAINER_NAME --rm -v /var/run/docker.sock:/var/run/docker.sock -v /tmp:/tmp -e CACHE_KEY=$CACHE_KEY $IMAGE_NAME



# Build the Docker image with cache
#docker buildx build --cache-from type=local,src=/tmp/docker_cache_$CACHE_KEY --cache-to type=local,dest=/tmp/docker_cache_$CACHE_KEY,mode=max -t myimage:latest .

# Save the cache to a tar file
docker save -o /tmp/docker_cache_$CACHE_KEY.tar pg-ferret-postgres-16:latest
8 changes: 1 addition & 7 deletions postgres/build-postgres.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,5 @@ sed -i 's/amd64 | arm64 | ppc64el | s390x/dummy/' Dockerfile

sed -i 's/apt-get source --compile "postgresql-$PG_MAJOR=$PG_VERSION"/apt-get source "postgresql-$PG_MAJOR=$PG_VERSION"; cd postgresql-*; sed -i '\''$a override_dh_strip:\\n\\t# Do nothing, which means dont strip the symbols\\n'\'' \/usr\/share\/postgresql-common\/server\/postgresql.mk; sed -i '\''s|$(CFLAGS)|-ggdb -Og -g3 -fno-omit-frame-pointer|'\'' \/usr\/share\/postgresql-common\/server\/postgresql.mk; cd ..; apt-get source --compile "postgresql-$PG_MAJOR=$PG_VERSION"/' Dockerfile

# Print the modified Dockerfile (for verification purposes)
cat Dockerfile

# Build the PostgreSQL image with debug symbols
docker build -t pg-ferret-postgres-16:latest .

# Indicate successful build
echo "PostgreSQL debug image built successfully"
docker buildx build --cache-from type=local,src=/tmp/$CACHE_KEY --cache-to type=local,dest=/tmp/$CACHE_KEY,mode=max -t pg-ferret-postgres-16:latest .

0 comments on commit 177eab4

Please sign in to comment.