Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the Makefile for local development #41

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 16 additions & 47 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,84 +1,53 @@
.PHONY: all dev 13dev 14dev 15dev prod attach before clean down server test up pushdev pushprod
.PHONY: local attach before clean down server test up pushdev

all: 12dev 13dev 14dev 15dev 16dev prod

dev: 16dev

12dev:
docker build --build-arg PGTARGET=12 -t pgautoupgrade/pgautoupgrade:12-dev .

13dev:
docker build --build-arg PGTARGET=13 -t pgautoupgrade/pgautoupgrade:13-dev .

14dev:
docker build --build-arg PGTARGET=14 -t pgautoupgrade/pgautoupgrade:14-dev .

15dev:
docker build --build-arg PGTARGET=15 -t pgautoupgrade/pgautoupgrade:15-dev .

16dev:
docker build -t pgautoupgrade/pgautoupgrade:16-dev -t pgautoupgrade/pgautoupgrade:dev .

prod:
docker build --build-arg PGTARGET=15 -t pgautoupgrade/pgautoupgrade:15-alpine3.20 -t pgautoupgrade/pgautoupgrade:15-alpine . && \
docker build -t pgautoupgrade/pgautoupgrade:16-alpine3.20 -t pgautoupgrade/pgautoupgrade:16-alpine -t pgautoupgrade/pgautoupgrade:latest .
local:
docker build -f Dockerfile.alpine -t pgautoupgrade/pgautoupgrade:local .

attach:
docker exec -it pgauto /bin/bash

before:
if [ ! -d "test/postgres-data" ]; then \
mkdir test/postgres-data; \
fi && \
fi
docker run --name pgauto -it --rm \
--mount type=bind,source=$(abspath $(CURDIR))/test/postgres-data,target=/var/lib/postgresql/data \
-e POSTGRES_PASSWORD=password \
-e PGAUTO_DEVEL=before \
pgautoupgrade/pgautoupgrade:dev
pgautoupgrade/pgautoupgrade:local

clean:
docker image rm --force pgautoupgrade/pgautoupgrade:dev pgautoupgrade/pgautoupgrade:12-dev pgautoupgrade/pgautoupgrade:13-dev \
pgautoupgrade/pgautoupgrade:14-dev pgautoupgrade/pgautoupgrade:15-dev pgautoupgrade/pgautoupgrade:16-dev \
pgautoupgrade/pgautoupgrade:15-alpine pgautoupgrade/pgautoupgrade:16-alpine \
pgautoupgrade/pgautoupgrade:15-alpine3.20 pgautoupgrade/pgautoupgrade:16-alpine3.20 pgautoupgrade/pgautoupgrade:latest && \
docker image prune -f && \
docker image rm --force \
pgautoupgrade/pgautoupgrade:dev \
pgautoupgrade/pgautoupgrade:local
docker image prune -f
docker volume prune -f

down:
./test.sh down
docker container stop pgauto

server:
if [ ! -d "test/postgres-data" ]; then \
mkdir test/postgres-data; \
fi && \
fi
docker run --name pgauto -it --rm --mount type=bind,source=$(abspath $(CURDIR))/test/postgres-data,target=/var/lib/postgresql/data \
-e POSTGRES_PASSWORD=password \
-e PGAUTO_DEVEL=server \
pgautoupgrade/pgautoupgrade:dev
pgautoupgrade/pgautoupgrade:local

test:
./test.sh

up:
if [ ! -d "test/postgres-data" ]; then \
mkdir test/postgres-data; \
fi && \
fi
docker run --name pgauto -it --rm \
--mount type=bind,source=$(abspath $(CURDIR))/test/postgres-data,target=/var/lib/postgresql/data \
-e POSTGRES_PASSWORD=password \
pgautoupgrade/pgautoupgrade:dev
pgautoupgrade/pgautoupgrade:local

pushdev:
docker push pgautoupgrade/pgautoupgrade:12-dev && \
docker push pgautoupgrade/pgautoupgrade:13-dev && \
docker push pgautoupgrade/pgautoupgrade:14-dev && \
docker push pgautoupgrade/pgautoupgrade:15-dev && \
docker push pgautoupgrade/pgautoupgrade:16-dev && \
docker tag pgautoupgrade/pgautoupgrade:local pgautoupgrade/pgautoupgrade:dev
docker push pgautoupgrade/pgautoupgrade:dev

pushprod:
docker push pgautoupgrade/pgautoupgrade:15-alpine3.20 && \
docker push pgautoupgrade/pgautoupgrade:15-alpine && \
docker push pgautoupgrade/pgautoupgrade:16-alpine3.20 && \
docker push pgautoupgrade/pgautoupgrade:16-alpine && \
docker push pgautoupgrade/pgautoupgrade:latest
docker image rm pgautoupgrade/pgautoupgrade:dev
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ To build the development docker image, use:
$ make dev
```

This will take a few minutes to create the "pgautoupgrade:latest"
This will take a few minutes to create the "pgautoupgrade:local"
docker image, that you can use in your docker-compose.yml
files.

Expand Down
11 changes: 7 additions & 4 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,9 @@ _main() {
# executing
local UPGRADE_PERFORMED=0
if [ "x${PGAUTO_DEVEL}" = "xbefore" ]; then
echo "---------------------------------------------------------------------------"
echo "In pgautoupgrade development mode, paused prior to pgautoupgrade scripting."
echo "---------------------------------------------------------------------------"
echo "--------------------------------------------------------------------------"
echo "In pgautoupgrade development mode, paused prior to pgautoupgrade scripting"
echo "--------------------------------------------------------------------------"
while :; do
sleep 5
done
Expand Down Expand Up @@ -588,7 +588,10 @@ _main() {
# For development of pgautoupgrade. This spot leaves the container running, after the pgautoupgrade scripting has
# executed, but without subsequently running the PostgreSQL server
if [ "x${PGAUTO_DEVEL}" = "xserver" ]; then
echo "In pgautoupgrade development mode, so database server not started."
echo "-------------------------------------------------------------------"
echo "In pgautoupgrade development mode, paused after main pg_upgrade has"
echo "run, but before database server and post-upgrade tasks have started"
echo "-------------------------------------------------------------------"
while :; do
sleep 5
done
Expand Down