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

feat(postgres): use docker's official postgres:11 image #4

Merged
merged 4 commits into from
Nov 14, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ RUN apt-get purge -y --auto-remove $BUILD_DEPS && \
COPY rootfs /
ENV WALE_ENVDIR=/etc/wal-e.d/env
RUN mkdir -p $WALE_ENVDIR
RUN python3 /patcher-script.py
RUN python3 /patcher-script.py /bin/create_bucket
RUN python3 /patcher-script.py /usr/local/bin/wal-e

CMD ["/docker-entrypoint.sh", "postgres"]
EXPOSE 5432
4 changes: 2 additions & 2 deletions rootfs/bin/create_bucket
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def bucket_exists(conn, name):
return True

bucket_name = os.getenv('BUCKET_NAME')
region = os.getenv('AWS_REGION')
region = os.getenv('S3_REGION')

if os.getenv('DATABASE_STORAGE') == "s3":
conn = boto.s3.connect_to_region(region)
Expand Down Expand Up @@ -85,6 +85,6 @@ else:
port=int(os.getenv('S3_PORT')),
calling_format=OrdinaryCallingFormat())
# HACK(bacongobbler): allow boto to connect to minio by changing the region name for s3v4 auth
conn.auth_region_name = os.getenv('AWS_REGION')
conn.auth_region_name = os.getenv('S3_REGION')
Cryptophobia marked this conversation as resolved.
Show resolved Hide resolved
if not bucket_exists(conn, bucket_name):
conn.create_bucket(bucket_name)
2 changes: 1 addition & 1 deletion rootfs/docker-entrypoint-initdb.d/001_setup_envdir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ if [[ "$DATABASE_STORAGE" == "s3" || "$DATABASE_STORAGE" == "minio" ]]; then
else
echo "1" > AWS_INSTANCE_PROFILE
fi
echo $AWS_REGION > AWS_REGION
echo $AWS_REGION > S3_REGION
echo $BUCKET_NAME > BUCKET_NAME
elif [ "$DATABASE_STORAGE" == "gcs" ]; then
GOOGLE_APPLICATION_CREDENTIALS="/var/run/secrets/deis/objectstore/creds/key.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def patch_wal_e_hmac_auth_v4_handler():
_init = HmacAuthV4Handler.__init__
def wrap_init(self, *args, **kwargs):
_init(self, *args, **kwargs)
self.region_name = os.getenv('AWS_REGION', self.region_name)
self.region_name = os.getenv('S3_REGION', self.region_name)
HmacAuthV4Handler.__init__ = wrap_init


Expand Down
10 changes: 6 additions & 4 deletions rootfs/patcher-script.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sys

patch_script = """

def run_patch_scripts(patch_script_path):
Expand All @@ -15,18 +17,18 @@ def run_patch_scripts(patch_script_path):
"""


def main():
def main(patch_file):
result_list = []
with open("/usr/local/bin/wal-e", "r") as f:
with open(patch_file, "r") as f:
has_patched = False
for line in f:
if not has_patched and line.startswith('import'):
result_list.append(patch_script)
has_patched = True
result_list.append(line)
with open("/usr/local/bin/wal-e", "w") as f:
with open(patch_file, "w") as f:
for line in result_list:
f.write(line)

if __name__ == '__main__':
main()
main(sys.argv[1])