From ec0c8f740c1b3f1ae8a1f98ab63b295d3ae55d86 Mon Sep 17 00:00:00 2001 From: Andrea Fazzi Date: Fri, 21 Feb 2020 11:43:01 +0100 Subject: [PATCH] Add some aws helper scripts --- Dockerfile.aws | 14 ++++++++++++++ bash/ecr-push.bash | 18 ++++++++++++++++++ bash/rds-connect.bash | 6 ++++++ config/config.aws.yaml | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 Dockerfile.aws create mode 100755 bash/ecr-push.bash create mode 100755 bash/rds-connect.bash create mode 100644 config/config.aws.yaml diff --git a/Dockerfile.aws b/Dockerfile.aws new file mode 100644 index 00000000..fb8481ec --- /dev/null +++ b/Dockerfile.aws @@ -0,0 +1,14 @@ +FROM golang:latest + +ENV PATH=$PATH:/src/oef/ +RUN mkdir -p /src/oef +ADD . /src/oef + +COPY config/config.aws.yaml /src/oef/config/config.yaml + +WORKDIR /src/oef/ + +RUN go build -o oef *.go +ENTRYPOINT ["/src/oef/oef"] + +EXPOSE 3000 diff --git a/bash/ecr-push.bash b/bash/ecr-push.bash new file mode 100755 index 00000000..14122e8d --- /dev/null +++ b/bash/ecr-push.bash @@ -0,0 +1,18 @@ +#!/bin/bash + +## Login + +aws ecr get-login-password | docker login --username AWS --password-stdin 185273882442.dkr.ecr.eu-central-1.amazonaws.com + +## Build the image + +docker build -f Dockerfile.aws -t oef . + +## Tag the image + +docker tag oef:latest 185273882442.dkr.ecr.eu-central-1.amazonaws.com/oef:latest + +## Push the image + +docker push 185273882442.dkr.ecr.eu-central-1.amazonaws.com/oef:latest + diff --git a/bash/rds-connect.bash b/bash/rds-connect.bash new file mode 100755 index 00000000..1e83ea37 --- /dev/null +++ b/bash/rds-connect.bash @@ -0,0 +1,6 @@ +#!/bin/bash + +RDSHOST="oef-free-tier.cjsemjfwbreb.eu-central-1.rds.amazonaws.com" +TOKEN="$(aws rds generate-db-auth-token --hostname $RDSHOST --port 3306 --region eu-central-1 --username admin)" +echo $TOKEN +mysql --host=$RDSHOST --port=3306 --ssl-ca=/sample_dir/rds-combined-ca-bundle.pem --enable-cleartext-plugin --user=admin --password=$TOKEN diff --git a/config/config.aws.yaml b/config/config.aws.yaml new file mode 100644 index 00000000..39f39c30 --- /dev/null +++ b/config/config.aws.yaml @@ -0,0 +1,33 @@ +url: "https://gara.olimpiadi-economiaefinanza.it" +domain: "olimpiadi-economiaefinanza.it" +log_level: 2 +language: "it" +jwt_expire_time: 120 + +keys: + cookie_store_key: "2a=UvD!" + jwt_signing_key: "ytOC>3," + +orm: + connection: "admin:remaccio1607@tcp(oef-micro.cjsemjfwbreb.eu-central-1.rds.amazonaws.com:3306)/oef_prod" + options: "charset=utf8&parseTime=True&loc=Local" + automigrate: true + reset: false + regenerate: false + +admin: + username: "admin" + password: "aolieVooju" + +subscriber: + password: "subscribe" + +smtp: + host: "smtps.aruba.it" + port: 465 + username: "supporto.informatico@olimpiadi-economiaefinanza.it" + password: "^7Ra~}zN" + subject: "[OEF2020] - Credenziali di accesso della scuola" + from: "noreply@olimpiadi-economiaefinanza.it" + bcc: "posta@andreafazzi.eu" +