Skip to content

Commit 42225fd

Browse files
author
Matthew Fisher
committed
chore(Dockerfile): bump to wal-e v1.0.1
See https://github.com/wal-e/wal-e/releases/tag/v1.0.1
1 parent a3e0a20 commit 42225fd

3 files changed

Lines changed: 50 additions & 60 deletions

File tree

Dockerfile

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ RUN adduser --system \
1515
--group \
1616
postgres
1717

18-
RUN buildDeps='gcc git libffi-dev libssl-dev python-dev python-pip python-wheel' && \
18+
RUN buildDeps='gcc git libffi-dev libssl-dev python3-dev python3-pip python3-wheel' && \
1919
localedef -i en_US -c -f UTF-8 -A /etc/locale.alias en_US.UTF-8 && \
2020
export DEBIAN_FRONTEND=noninteractive && \
2121
apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 && \
@@ -28,17 +28,21 @@ RUN buildDeps='gcc git libffi-dev libssl-dev python-dev python-pip python-wheel'
2828
postgresql-$PG_MAJOR=$PG_VERSION \
2929
postgresql-contrib-$PG_MAJOR=$PG_VERSION \
3030
pv \
31-
python \
31+
python3 \
3232
postgresql-common \
3333
util-linux \
3434
# swift package needs pkg_resources and setuptools
35-
python-pkg-resources \
36-
python-setuptools && \
35+
python3-pkg-resources \
36+
python3-setuptools && \
37+
ln -sf /usr/bin/python3 /usr/bin/python && \
38+
ln -sf /usr/bin/pip3 /usr/bin/pip && \
3739
mkdir -p /run/postgresql && \
3840
chown -R postgres /run/postgresql && \
39-
pip install --disable-pip-version-check --no-cache-dir git+https://github.com/deis/wal-e.git@380821a6c4ea4f98a244680d7c6c5b04b8c694b3 \
40-
google-gax===0.12.5 \
41-
envdir && \
41+
pip install --disable-pip-version-check --no-cache-dir \
42+
envdir==0.7 \
43+
wal-e[aws,azure,google,swift]==v1.0.1 && \
44+
# "upgrade" boto to 2.42.0 + the patch to fix minio connections
45+
pip install --disable-pip-version-check --no-cache-dir --upgrade git+https://github.com/deis/boto@c1e71a737bef48f934b6108c06a84e483173a2da && \
4246
# cleanup
4347
apt-get purge -y --auto-remove $buildDeps && \
4448
apt-get autoremove -y && \

rootfs/bin/create_bucket

Lines changed: 30 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,50 @@
22

33
import os
44

5-
import boto3
6-
import botocore
5+
import boto
76
import json
87
import swiftclient
9-
from botocore.utils import fix_s3_host
10-
from botocore.client import Config
8+
from boto import config as botoconfig
9+
from boto.s3.connection import S3Connection, OrdinaryCallingFormat
1110
from oauth2client.service_account import ServiceAccountCredentials
1211
from gcloud.storage.client import Client
1312
from gcloud import exceptions
14-
from azure.storage.blob import BlockBlobService
13+
from azure.storage.blob import BlobService
14+
15+
def bucket_exists(conn, name):
16+
bucket = conn.lookup(name)
17+
if not bucket:
18+
return False
19+
return True
1520

1621
bucket_name = os.getenv('BUCKET_NAME')
1722

1823
if os.getenv('DATABASE_STORAGE') == "s3":
19-
conn = boto3.resource('s3')
20-
exists = True
21-
try:
22-
conn.meta.client.head_bucket(Bucket=bucket_name)
23-
except botocore.exceptions.ClientError as e:
24-
# If a client error is thrown, then check that it was a 404 error.
25-
# If it was a 404 error, then the bucket does not exist.
26-
error_code = int(e.response['Error']['Code'])
27-
if error_code == 404:
28-
exists = False
29-
else:
30-
raise
24+
conn = boto.connect_s3()
3125

32-
if not exists:
33-
conn.create_bucket(Bucket=bucket_name)
26+
if not bucket_exists(conn, bucket_name):
27+
conn.create_bucket(bucket_name)
3428

3529
elif os.getenv('DATABASE_STORAGE') == "gcs":
3630
scopes = ['https://www.googleapis.com/auth/devstorage.full_control']
3731
credentials = ServiceAccountCredentials.from_json_keyfile_name(os.getenv('GS_APPLICATION_CREDS'), scopes=scopes)
3832
with open(os.getenv('GS_APPLICATION_CREDS')) as data_file:
3933
data = json.load(data_file)
40-
client = Client(credentials=credentials, project=data['project_id'])
34+
conn = Client(credentials=credentials, project=data['project_id'])
4135
exists = True
4236
try:
43-
client.get_bucket(bucket_name)
37+
conn.get_bucket(bucket_name)
4438
except exceptions.NotFound:
4539
exists = False
4640
except:
4741
raise
4842
if not exists:
49-
client.create_bucket(bucket_name)
43+
conn.create_bucket(bucket_name)
5044

5145
elif os.getenv('DATABASE_STORAGE') == "azure":
52-
block_blob_service = BlockBlobService(account_name=os.getenv('WABS_ACCOUNT_NAME'), account_key=os.getenv('WABS_ACCESS_KEY'))
46+
conn = BlobService(account_name=os.getenv('WABS_ACCOUNT_NAME'), account_key=os.getenv('WABS_ACCESS_KEY'))
5347
#It doesn't throw an exception if the container exists by default(https://github.com/Azure/azure-storage-python/blob/master/azure/storage/blob/baseblobservice.py#L504).
54-
block_blob_service.create_container(bucket_name)
48+
conn.create_container(bucket_name)
5549

5650
elif os.getenv('DATABASE_STORAGE') == "swift":
5751
conn = swiftclient.Connection(
@@ -65,20 +59,15 @@ elif os.getenv('DATABASE_STORAGE') == "swift":
6559
conn.put_container(os.getenv('BUCKET_NAME'))
6660

6761
else:
68-
conn = boto3.resource('s3', endpoint_url=os.getenv('S3_URL'), config=Config(signature_version='s3v4'))
69-
# stop boto3 from automatically changing the endpoint
70-
conn.meta.client.meta.events.unregister('before-sign.s3', fix_s3_host)
71-
exists = True
72-
try:
73-
conn.meta.client.head_bucket(Bucket=bucket_name)
74-
except botocore.exceptions.ClientError as e:
75-
# If a client error is thrown, then check that it was a 404 error.
76-
# If it was a 404 error, then the bucket does not exist.
77-
error_code = int(e.response['Error']['Code'])
78-
if error_code == 404:
79-
exists = False
80-
else:
81-
raise
82-
83-
if not exists:
84-
conn.create_bucket(Bucket=bucket_name)
62+
botoconfig.add_section('s3')
63+
botoconfig.set('s3', 'use-sigv4', 'True')
64+
botoconfig.add_section('Boto')
65+
botoconfig.set('Boto', 'is_secure', 'False')
66+
conn = S3Connection(
67+
host=os.getenv('S3_HOST'),
68+
port=int(os.getenv('S3_PORT')),
69+
calling_format=OrdinaryCallingFormat())
70+
# HACK(bacongobbler): allow boto to connect to minio by changing the region name for s3v4 auth
71+
conn.auth_region_name = os.getenv('AWS_REGION')
72+
if not bucket_exists(conn, bucket_name):
73+
conn.create_bucket(bucket_name)

rootfs/docker-entrypoint-initdb.d/001_setup_envdir.sh

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,22 @@ if [[ "$DATABASE_STORAGE" == "s3" || "$DATABASE_STORAGE" == "minio" ]]; then
66
AWS_ACCESS_KEY_ID=$(cat /var/run/secrets/deis/objectstore/creds/accesskey)
77
AWS_SECRET_ACCESS_KEY=$(cat /var/run/secrets/deis/objectstore/creds/secretkey)
88
if [[ "$DATABASE_STORAGE" == "s3" ]]; then
9-
AWS_DEFAULT_REGION=$(cat /var/run/secrets/deis/objectstore/creds/region)
9+
AWS_REGION=$(cat /var/run/secrets/deis/objectstore/creds/region)
1010
BUCKET_NAME=$(cat /var/run/secrets/deis/objectstore/creds/database-bucket)
1111
else
12-
# these only need to be set if we're not accessing S3 (boto will figure this out)
13-
echo "http://$DEIS_MINIO_SERVICE_HOST:$DEIS_MINIO_SERVICE_PORT" > WALE_S3_ENDPOINT
14-
if [ "$DEIS_MINIO_SERVICE_PORT" == "80" ]; then
15-
# If you add port 80 to the end of the endpoint_url, boto3 freaks out.
16-
# God I hate boto3 some days.
17-
echo "http://$DEIS_MINIO_SERVICE_HOST" > S3_URL
18-
else
19-
echo "http://$DEIS_MINIO_SERVICE_HOST:$DEIS_MINIO_SERVICE_PORT" > S3_URL
20-
fi
21-
AWS_DEFAULT_REGION="us-east-1"
12+
AWS_REGION="us-east-1"
2213
BUCKET_NAME="dbwal"
14+
# these only need to be set if we're not accessing S3 (boto will figure this out)
15+
echo "http+path://s3-$AWS_REGION.$DEIS_MINIO_SERVICE_HOST:$DEIS_MINIO_SERVICE_PORT" > WALE_S3_ENDPOINT
16+
echo "$DEIS_MINIO_SERVICE_HOST" > S3_HOST
17+
echo "$DEIS_MINIO_SERVICE_PORT" > S3_PORT
18+
# enable sigv4 authentication
19+
echo "true" > S3_USE_SIGV4
2320
fi
2421
echo "s3://$BUCKET_NAME" > WALE_S3_PREFIX
2522
echo $AWS_ACCESS_KEY_ID > AWS_ACCESS_KEY_ID
2623
echo $AWS_SECRET_ACCESS_KEY > AWS_SECRET_ACCESS_KEY
27-
echo $AWS_DEFAULT_REGION > AWS_DEFAULT_REGION
24+
echo $AWS_REGION > AWS_REGION
2825
echo $BUCKET_NAME > BUCKET_NAME
2926
elif [ "$DATABASE_STORAGE" == "gcs" ]; then
3027
GS_APPLICATION_CREDS="/var/run/secrets/deis/objectstore/creds/key.json"

0 commit comments

Comments
 (0)