Skip to content

Commit

Permalink
Merge pull request #87 from michaelbeutler/develop
Browse files Browse the repository at this point in the history
Upgraded `Dockerfile` to newer versions.
  • Loading branch information
JamesClonk authored May 1, 2024
2 parents 8b00d99 + 17e759c commit 58d2bcb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 28 deletions.
19 changes: 9 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
build:
docker:
# primary image for building app
- image: cimg/go:1.16-node
- image: cimg/go:1.21-node

# service images available at `host: localhost`
- image: circleci/postgres:12-alpine
Expand Down Expand Up @@ -79,24 +79,23 @@ jobs:
chmod +x jq
sudo mv jq /usr/local/bin/jq
# postgres integration tests
- run:
name: install Postgres client
name: install Postgres client v15
command: |
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt buster-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt jammy-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install postgresql-client-12
sudo apt-get -y install postgresql-client-15
- run: make postgres-test

# mongodb integration tests
- run:
name: install MongoDB client
name: install MongoDB client v7
command: |
wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg --dearmor && \
sudo echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | \
sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
sudo apt-get update
sudo apt-get install -y mongodb-database-tools=100.5.1 mongodb-org-tools=5.0.5 mongodb-org-shell=5.0.5
sudo apt-get install -y mongodb-database-tools=100.9.0 mongodb-org-tools=7.0.7 mongodb-org-shell=7.0.7 mongodb-mongosh=2.2.2
- run: make mongodb-test

# redis integration tests
Expand Down
17 changes: 10 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM --platform=linux/amd64 ubuntu:22.04

ARG package_args='--allow-downgrades --allow-remove-essential --allow-change-held-packages --no-install-recommends'
RUN echo "debconf debconf/frontend select noninteractive" | debconf-set-selections && \
Expand All @@ -17,7 +17,7 @@ WORKDIR /go/src/github.com/swisscom/backman
COPY . .
RUN go build -o backman

FROM ubuntu:20.04
FROM --platform=linux/amd64 ubuntu:22.04
LABEL maintainer="JamesClonk <jamesclonk@jamesclonk.ch>"

ARG package_args='--allow-downgrades --allow-remove-essential --allow-change-held-packages --no-install-recommends'
Expand All @@ -27,13 +27,16 @@ RUN echo "debconf debconf/frontend select noninteractive" | debconf-set-selectio
apt-get -y $package_args dist-upgrade && \
apt-get -y $package_args install curl wget ca-certificates gnupg tzdata

RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \
echo "deb http://apt.postgresql.org/pub/repos/apt/ focal-pgdg main" > /etc/apt/sources.list.d/pgdg.list
RUN wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | apt-key add - && \
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse" > /etc/apt/sources.list.d/mongodb-org-5.0.list
RUN sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt jammy-pgdg main" > /etc/apt/sources.list.d/pgdg.list' \
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
RUN curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | \
gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg \
--dearmor && \
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | \
tee /etc/apt/sources.list.d/mongodb-org-7.0.list
RUN curl -sL https://deb.nodesource.com/setup_lts.x | bash -
RUN apt-get -y $package_args update && \
apt-get -y $package_args install mysql-client postgresql-client-12 mongodb-database-tools=100.5.4 mongodb-org-tools=5.0.13 mongodb-org-shell=5.0.13 redis-tools nodejs openssh-server bash vim-tiny && \
apt-get -y $package_args install mysql-client postgresql-client-15 mongodb-database-tools=100.9.0 mongodb-org-tools=7.0.7 mongodb-org-shell=7.0.7 redis-tools nodejs openssh-server bash vim-tiny && \
apt-get clean && \
find /usr/share/doc/*/* ! -name copyright | xargs rm -rf && \
rm -rf \
Expand Down
22 changes: 11 additions & 11 deletions scripts/mongodb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ retry() {

# =============================================================================================
echo "waiting on mongodb ..."
retry 10 mongo --host 127.0.0.1 -u 'mongoadmin' -p 'super-secret' --authenticationDatabase admin --quiet --eval 'db.runCommand("ping").ok'
retry 10 mongosh --host 127.0.0.1 -u 'mongoadmin' -p 'super-secret' --authenticationDatabase admin --quiet --eval 'db.runCommand("ping").ok'
echo "mongodb is up!"

# =============================================================================================
Expand Down Expand Up @@ -72,7 +72,7 @@ fi
curl -s http://john:doe@127.0.0.1:9990/api/v1/state/mongodb/my_mongodb | grep '"Status":"idle"'

# write to mongodb
mongo --host 127.0.0.1 -u 'mongoadmin' -p 'super-secret' --authenticationDatabase admin <<EOF
mongosh --host 127.0.0.1 -u 'mongoadmin' -p 'super-secret' --authenticationDatabase admin <<EOF
db.inventory.insertMany([
{ item: "my_backup_item_a", status: "test" },
{ item: "my_backup_item_b", status: "test" }
Expand All @@ -87,15 +87,15 @@ sleep 15
curl -s http://john:doe@127.0.0.1:9990/api/v1/state/mongodb/my_mongodb | grep '"Operation":"backup"' | grep '"Status":"success"'

# read from mongodb
mongo --host 127.0.0.1 -u 'mongoadmin' -p 'super-secret' --authenticationDatabase admin --eval 'db.inventory.find( { status: "test" } );' | grep 'my_backup_item_a'
mongo --host 127.0.0.1 -u 'mongoadmin' -p 'super-secret' --authenticationDatabase admin --eval 'db.inventory.find( { status: "test" } );' | grep 'my_backup_item_b'
mongosh --host 127.0.0.1 -u 'mongoadmin' -p 'super-secret' --authenticationDatabase admin --eval 'db.inventory.find( { status: "test" } );' | grep 'my_backup_item_a'
mongosh --host 127.0.0.1 -u 'mongoadmin' -p 'super-secret' --authenticationDatabase admin --eval 'db.inventory.find( { status: "test" } );' | grep 'my_backup_item_b'

# delete from mongodb
mongo --host 127.0.0.1 -u 'mongoadmin' -p 'super-secret' --authenticationDatabase admin --eval 'db.inventory.deleteMany( { item: "my_backup_item_a" } );'
mongo --host 127.0.0.1 -u 'mongoadmin' -p 'super-secret' --authenticationDatabase admin --eval 'db.inventory.insert({ item: "my_backup_item_c", status: "test" });'
mongosh --host 127.0.0.1 -u 'mongoadmin' -p 'super-secret' --authenticationDatabase admin --eval 'db.inventory.deleteMany( { item: "my_backup_item_a" } );'
mongosh --host 127.0.0.1 -u 'mongoadmin' -p 'super-secret' --authenticationDatabase admin --eval 'db.inventory.insert({ item: "my_backup_item_c", status: "test" });'
sleep 2
mongo --host 127.0.0.1 -u 'mongoadmin' -p 'super-secret' --authenticationDatabase admin --eval 'db.inventory.find( { status: "test" } );' | grep 'my_backup_item_c'
mongo --host 127.0.0.1 -u 'mongoadmin' -p 'super-secret' --authenticationDatabase admin --eval 'db.inventory.find( { status: "test" } );' | grep -v 'my_backup_item_a'
mongosh --host 127.0.0.1 -u 'mongoadmin' -p 'super-secret' --authenticationDatabase admin --eval 'db.inventory.find( { status: "test" } );' | grep 'my_backup_item_c'
mongosh --host 127.0.0.1 -u 'mongoadmin' -p 'super-secret' --authenticationDatabase admin --eval 'db.inventory.find( { status: "test" } );' | grep -v 'my_backup_item_a'

# trigger restore
FILENAME=$(curl -s http://john:doe@127.0.0.1:9990/api/v1/backup/mongodb/my_mongodb | jq -r .Files[0].Filename)
Expand All @@ -105,9 +105,9 @@ sleep 15
curl -s http://john:doe@127.0.0.1:9990/api/v1/state/mongodb/my_mongodb | grep '"Operation":"restore"' | grep '"Status":"success"'

# read from mongodb
mongo --host 127.0.0.1 -u 'mongoadmin' -p 'super-secret' --authenticationDatabase admin --eval 'db.inventory.find( { status: "test" } );' | grep -v 'my_backup_item_c'
mongo --host 127.0.0.1 -u 'mongoadmin' -p 'super-secret' --authenticationDatabase admin --eval 'db.inventory.find( { status: "test" } );' | grep 'my_backup_item_a'
mongo --host 127.0.0.1 -u 'mongoadmin' -p 'super-secret' --authenticationDatabase admin --eval 'db.inventory.find( { status: "test" } );' | grep 'my_backup_item_b'
mongosh --host 127.0.0.1 -u 'mongoadmin' -p 'super-secret' --authenticationDatabase admin --eval 'db.inventory.find( { status: "test" } );' | grep -v 'my_backup_item_c'
mongosh --host 127.0.0.1 -u 'mongoadmin' -p 'super-secret' --authenticationDatabase admin --eval 'db.inventory.find( { status: "test" } );' | grep 'my_backup_item_a'
mongosh --host 127.0.0.1 -u 'mongoadmin' -p 'super-secret' --authenticationDatabase admin --eval 'db.inventory.find( { status: "test" } );' | grep 'my_backup_item_b'

# delete backup
curl -X DELETE http://john:doe@127.0.0.1:9990/api/v1/backup/mongodb/my_mongodb/${FILENAME}
Expand Down

0 comments on commit 58d2bcb

Please sign in to comment.