Skip to content

Commit

Permalink
Move existing Dockerfile
Browse files Browse the repository at this point in the history
move existing Dockerfile in a separate docker folder to avoid overwritting it with the one generated by tpaexec execution environment.
  • Loading branch information
JonathanRenon-EDB committed Jun 18, 2024
1 parent bb5f315 commit 5bb6e6b
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 83 deletions.
83 changes: 0 additions & 83 deletions Dockerfile

This file was deleted.

63 changes: 63 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# © Copyright EnterpriseDB UK Limited 2015-2024 - All rights reserved.

# Build this container image like this
#
# docker build -t tpaexec:$(git describe --tags) -t tpaexec:latest .

# To use the container image, create a shell alias like this
#
# alias tpaexec="docker run --rm -v $PWD:/work -v $HOME/.git:/root/.git -v $HOME/.gitconfig:/root/.gitconfig \
# -v /var/run/docker.sock:/var/run/docker.sock \
# -e USER_ID=$(id -u) -e GROUP_ID=$(id -g) tpaexec"
#
# Then run commands like this
#
# tpaexec configure cluster -a M1 --postgresql 15 --failover-manager patroni --platform docker
# tpaexec deploy cluster

FROM debian:bookworm-slim

LABEL maintainer="EDB <[email protected]>"

# Copy tpaexec sources from the current directory into the image
ENV TPA_DIR=/opt/EDB/TPA

COPY . ${TPA_DIR}

# Set up repositories and install packages, including the Docker CE CLI
# (https://docs.docker.com/engine/install/debian/).

RUN apt-get -y update && \
apt-get -y install --no-install-recommends \
curl gnupg apt-transport-https \
python3 python3-dev python3-pip python3-venv \
openvpn patch git gcc && \
curl -fsSL https://download.docker.com/linux/debian/gpg >/etc/apt/trusted.gpg.d/docker.asc && \
codename=$(awk -F= '/VERSION_CODENAME/{print $2}' /etc/os-release) && \
arch=$(dpkg --print-architecture) && \
echo "deb [arch=$arch] https://download.docker.com/linux/debian $codename stable" \
>/etc/apt/sources.list.d/docker.list && \
apt-get -y update && \
apt-get -y install --no-install-recommends docker-ce-cli && \
\
# run `tpaexec setup` to complete the installation, and then `tpaexec selftest` to verify it. \
\
ln -sf ${TPA_DIR}/bin/tpaexec /usr/local/bin && \
mkdir /opt/2ndQuadrant/ && \
ln -sf ${TPA_DIR} /opt/2ndQuadrant/TPA && \
tpaexec setup --use-community-ansible && \
tpaexec selftest && \
(cd "${TPA_DIR}" && git describe --tags >VERSION) && \
\
# Clean up unnecessary files and packages \
\
rm -rf ${TPA_DIR}/.[a-z]* && \
apt purge -y gcc python3-dev python3-pip python3-venv build-essential && \
apt autoremove -y && \
apt autoclean -y && \
apt clean -y && \
rm -rf /var/cache/apt /var/lib/apt/lists

WORKDIR /work
CMD ["--help"]
ENTRYPOINT ["/opt/EDB/TPA/entrypoint.sh"]
24 changes: 24 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Run TPA from a docker container

This Dockerfile should be used to run tpa from a container.

Build this container image like this from TPA source folder

``` bash
docker build -f docker/Dockerfile -t tpaexec:$(git describe --tags) -t tpaexec:latest .
```

To use the container image, create a shell alias like this

``` bash
alias tpaexec="docker run --rm -v $PWD:/work -v $HOME/.git:/root/.git -v $HOME/.gitconfig:/root/.gitconfig \
-v /var/run/docker.sock:/var/run/docker.sock \
-e USER_ID=$(id -u) -e GROUP_ID=$(id -g) tpaexec"
```

Then run commands like this

``` bash
tpaexec configure cluster -a M1 --postgresql 15 --failover-manager patroni --platform docker
tpaexec deploy cluster
```

0 comments on commit 5bb6e6b

Please sign in to comment.