From 3dcf9b178a68d7c4019119fc951826785c1ef0fa Mon Sep 17 00:00:00 2001 From: Jacky Date: Tue, 4 Jul 2023 00:23:09 +0800 Subject: [PATCH] Add heroku.yml Init the db set the port set the port in the src Remove entry point Remove init: run heroku remove run from heroku.yml copy run-heroku change to 3000 databunker-heroku edit --- Dockerfile | 6 ++-- databunker-heroku.yaml | 80 ++++++++++++++++++++++++++++++++++++++++++ heroku.yml | 5 +++ run-heroku.sh | 16 +++++++++ src/bunker.go | 2 +- 5 files changed, 105 insertions(+), 4 deletions(-) create mode 100644 databunker-heroku.yaml create mode 100644 heroku.yml create mode 100755 run-heroku.sh diff --git a/Dockerfile b/Dockerfile index e908e24c..4b67cd48 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,7 @@ COPY --from=builder /lib/ld* /lib/libssl.* /lib/libcrypto.* /lib/ COPY --from=builder /etc/group /etc/ COPY --from=builder /etc/ssl /etc/ssl -COPY databunker.yaml /databunker/conf/ +COPY databunker*.yaml /databunker/conf/ RUN /bin/busybox mkdir -p /databunker/data && \ /bin/busybox mkdir -p /databunker/certs && \ /bin/busybox ln -s /bin/busybox /bin/addgroup && \ @@ -35,8 +35,8 @@ RUN /bin/busybox mkdir -p /databunker/data && \ addgroup -S appgroup && adduser --no-create-home -S appuser -G appgroup && \ chown appuser:appgroup /databunker/data USER appuser -COPY --from=builder /go/bin/databunker /go/src/securitybunker/databunker/run.sh /go/src/securitybunker/databunker/health-check.sh /databunker/bin/ +COPY --from=builder /go/bin/databunker /go/src/securitybunker/databunker/run*.sh /go/src/securitybunker/databunker/health-check.sh /databunker/bin/ EXPOSE 3000 HEALTHCHECK --interval=5s --timeout=3s --start-period=33s --retries=3 CMD /databunker/bin/health-check.sh -ENTRYPOINT ["/bin/sh", "/databunker/bin/run.sh"] +ENTRYPOINT ["/bin/sh", "/databunker/bin/run-heroku.sh"] #CMD ["/bin/sh", "-x", "-c", "/go/bin/databunker -init"] diff --git a/databunker-heroku.yaml b/databunker-heroku.yaml new file mode 100644 index 00000000..b9cc672e --- /dev/null +++ b/databunker-heroku.yaml @@ -0,0 +1,80 @@ +# Server configurations +generic: + # allow to create user object without login + create_user_without_access_token: true + # use separate app tables, default false + # use_separate_app_tables: true + # specify if API call to list users is available (default false) + # list_users: true +selfservice: + # specifies if user can remove himself withour Admin/DPO approval (default false) + forget_me: false + # specifies if user can change his data without Admin/DPO approval (default false) + user_record_change: true + # specifies a list of app-data objects user can change without approval + app_record_change: ["*"] +notification: + # url that receives notifications: + # - bad login + # - forget me + # - user profile change + # - consent change + # user details are send as json data. + #notification_url: "https://httpbin.org/post" +policy: + # max time to store records, untill they are deleted + max_user_retention_period: "3m" + max_audit_retention_period: "6m" + max_session_retention_period: "1h" + max_shareable_record_retention_period: "1m" +#ssl: +# # ssl configuration +# ssl_certificate: "/databunker/certs/server.cer" +# ssl_certificate_key: "/databunker/certs/server.key" +sms: + # REQUIRED: Specify SMS gateway URL. + # Available modifiers for url parameters: {token}, {from}, {phone}, {msg} + # url: "https://sms-gateway.com/send?token=_TOKEN_&from=_FROM_&phone=_PHONE_&msg=_MSG_" + # OPTIONAL: Specify From address + # from: "" + # OPTIONAL: Specify SMS gateway access token + # token: "" + # OPTIONAL: Specify SMS gateway Basic Auth header, format: username:password + # basic_auth: "user:pssword" + # OPTIONAL: Specify SMS gateway HTTP request method: GET or POST. Default is GET + # method: "GET" + # OPTIONAL: Specify SMS gateway HTTP request custom header. Can be used for authorization. + # custom_header: "x-token: value" + # OTIONAL: Specify SMS gateway HTTP request Content Type. It can be application/json. + # By default application/x-www-form-urlencoded + # content_type: "json" + # REQUIRED FOR POST REQUEST: POST body. Available modifiers: _TOKEN_, _FROM_, _PHONE_, _MSG_ + # Example for application/json POST request: + # body: '{"from":"_FROM_","phone":"_PHONE_","message":"_MSG_"}' + # Example for application/x-www-form-urlencoded POST request + # body: 'from=_FROM_&phone=_PHONE_&message=_MSG_' + # default country when sending out SMS + # Use country code when normalizing phone numbers. Use country code as defined here: + # https://github.com/ttacon/libphonenumber/blob/master/countrycodetoregionmap.go + default_country: "GB" +server: + host: "0.0.0.0" +# port: 3000 +smtp: + # You need to get SMTP server to send out email notification for example to allow user login. + # You can look for a email service company offering SMTP services. You can pick from here: + # https://privacybunker.io/blog/european-cloud-saas-vendors/ + server: "email-smtp-server.com" + port: 587 + user: "user@your-company.com" + pass: "" + sender: "bot@databunker.your-company.com" +ui: + logo_link: "/site/img/logo-example.png" + company_title: "Your company here" + company_link: "https://privacybunker.io/" + term_of_service_title: "Your Terms of service link" + term_of_service_link: "https://privacybunker.io/" + privacy_policy_title: "Your Privacy Policy link" + privacy_policy_link: "https://privacybunker.io/" + custom_css_link: "" diff --git a/heroku.yml b/heroku.yml new file mode 100644 index 00000000..7a55bdc2 --- /dev/null +++ b/heroku.yml @@ -0,0 +1,5 @@ +build: + docker: + web: Dockerfile + + diff --git a/run-heroku.sh b/run-heroku.sh new file mode 100755 index 00000000..97dfbdbc --- /dev/null +++ b/run-heroku.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +if [ -z "$DATABUNKER_MASTERKEY" ]; then + echo "DATABUNKER_MASTERKEY environment value is empty" + /bin/busybox sleep 60 + exit +fi + +echo "-------------ENV-------------" +/bin/busybox env + +echo "-------------FIND------------" +/bin/busybox find /databunker + +echo "-------------RUN-------------" +/databunker/bin/databunker -start -db $PGSQL_DB -conf /databunker/conf/databunker-heroku.yaml diff --git a/src/bunker.go b/src/bunker.go index 952fd428..6ae0b0f7 100644 --- a/src/bunker.go +++ b/src/bunker.go @@ -80,7 +80,7 @@ type Config struct { DefaultCountry string `yaml:"default_country"` } Server struct { - Port string `yaml:"port" envconfig:"BUNKER_PORT"` + Port string `yaml:"port" envconfig:"PORT"` Host string `yaml:"host" envconfig:"BUNKER_HOST"` } `yaml:"server"` SMTP struct {