multiple environments.
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
{:db {:server "database"}
|
||||
:scheme "https"
|
||||
:jwt-secret "auto ap invoices are awesome"}
|
||||
:jwt-secret "auto ap invoices are awesome"
|
||||
:aws-access-key-id "AKIAISQDBHDDBYVHNXMQ"
|
||||
:aws-secret-access-key "emIzqz9zW+5WrbJHwc1MI0gSS9IXF5feFFxnQI+7"
|
||||
:aws-region "us-east-1"
|
||||
:invoice-import-queue-url "https://sqs.us-east-1.amazonaws.com/679918342773/integreat-mail-prod"
|
||||
}
|
||||
|
||||
@@ -2,18 +2,21 @@ version: '3'
|
||||
services:
|
||||
nginx-proxy:
|
||||
restart: always
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
- /opt/integreat/certs/:/etc/nginx/certs:ro
|
||||
- /opt/integreat/etc/nginx/vhost.d:/etc/nginx/vhost.d
|
||||
- /opt/integreat/usr/share/nginx/html:/usr/share/nginx/html
|
||||
- /opt/integreat/prod/certs/:/etc/nginx/certs:ro
|
||||
- /opt/integreat/prod/etc/nginx/vhost.d:/etc/nginx/vhost.d
|
||||
- /opt/integreat/prod/usr/share/nginx/html:/usr/share/nginx/html
|
||||
letsencrypt:
|
||||
restart: always
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
- /opt/integreat/certs/:/etc/nginx/certs
|
||||
- /opt/integreat/etc/nginx/vhost.d:/etc/nginx/vhost.d
|
||||
- /opt/integreat/usr/share/nginx/html:/usr/share/nginx/html
|
||||
- /opt/integreat/prod/certs/:/etc/nginx/certs
|
||||
- /opt/integreat/prod/etc/nginx/vhost.d:/etc/nginx/vhost.d
|
||||
- /opt/integreat/prod/usr/share/nginx/html:/usr/share/nginx/html
|
||||
app:
|
||||
restart: always
|
||||
environment:
|
||||
@@ -24,4 +27,4 @@ services:
|
||||
database:
|
||||
restart: always
|
||||
volumes:
|
||||
- /opt/integreat/var/lib/postgresql/data:/var/lib/postgresql/data
|
||||
- /opt/integreat/prod/var/lib/postgresql/data:/var/lib/postgresql/data
|
||||
|
||||
@@ -2,9 +2,6 @@ version: '3'
|
||||
services:
|
||||
nginx-proxy:
|
||||
image: jwilder/nginx-proxy:alpine
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
labels:
|
||||
- "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true"
|
||||
volumes:
|
||||
@@ -26,12 +23,10 @@ services:
|
||||
depends_on:
|
||||
- database
|
||||
environment:
|
||||
config: /usr/local/config/prod.edn
|
||||
config: /usr/local/config/local.edn
|
||||
VIRTUAL_HOST: local.integreat.aws.brycecovertoperations.com
|
||||
database:
|
||||
image: postgres:9-alpine
|
||||
ports:
|
||||
- 5432:5432
|
||||
environment:
|
||||
POSTGRES_USER: ap
|
||||
POSTGRES_PASSWORD: fifteen-invoices-imported!
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
[clojure-mail.message :as message]
|
||||
[clojure.string :as str]
|
||||
[clojure.java.io :as io]
|
||||
[config.core :refer [env]]
|
||||
[auto-ap.parse :as parse]
|
||||
[auto-ap.db.invoices :as invoices]
|
||||
[auto-ap.db.companies :as companies]
|
||||
@@ -20,13 +21,12 @@
|
||||
Flags$Flag AuthenticationFailedException]
|
||||
(com.sun.mail.imap IMAPStore)))
|
||||
|
||||
(def queue-url "https://sqs.us-east-1.amazonaws.com/679918342773/integreat-mail-prod")
|
||||
|
||||
(defn process-sqs []
|
||||
(try
|
||||
(println "Fetching messages from sqs...")
|
||||
(let [companies (companies/get-all)]
|
||||
(doseq [message (:messages (sqs/receive-message {:queue-url queue-url
|
||||
(doseq [message (:messages (sqs/receive-message {:queue-url (:invoice-import-queue-url env)
|
||||
:wait-time-seconds 5
|
||||
:max-number-of-messages 10
|
||||
#_#_:attribute-names ["All"]}))]
|
||||
@@ -46,7 +46,7 @@
|
||||
(io/copy (:body pdf-stream) (io/file filename))
|
||||
(invoices/import (parse/parse-file filename filename) companies)
|
||||
(io/delete-file filename))))))
|
||||
(sqs/delete-message (assoc message :queue-url queue-url ))))
|
||||
(sqs/delete-message (assoc message :queue-url (:invoice-import-queue-url env) ))))
|
||||
(catch Exception e
|
||||
(println e))))
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
[auto-ap.routes.auth :as auth]
|
||||
[amazonica.core :refer [defcredential]]))
|
||||
|
||||
(defcredential "AKIAINHACMVQJ6NYD26A" "FwdL4TbIC/5H/4mwhQy4iSI/eSewyPgfS1EEt6tL" "us-east-1")
|
||||
(defcredential (:aws-access-key-id env) (:aws-secret-access-key env) (:aws-region env))
|
||||
|
||||
(defroutes static-routes
|
||||
(GET "/" [] (response/resource-response "index.html" {:root "public"}))
|
||||
|
||||
@@ -39,8 +39,7 @@
|
||||
(defn find-ready-reminders []
|
||||
(let [vendors (vendors/get-all)
|
||||
ready-reminders (reminders/get-ready)]
|
||||
ready-reminders
|
||||
))
|
||||
ready-reminders))
|
||||
|
||||
(defn send-emails [reminders]
|
||||
(doseq [{:keys [vendor-name email id]} reminders]
|
||||
|
||||
@@ -6,6 +6,9 @@ provider "aws" {
|
||||
|
||||
variable "aws_secret_access_key" {}
|
||||
variable "aws_access_key_id" {}
|
||||
variable "domain" {}
|
||||
variable "base_url" {}
|
||||
variable "invoice_address" {}
|
||||
variable "stage" {}
|
||||
|
||||
data "aws_caller_identity" "current" {}
|
||||
@@ -18,13 +21,13 @@ resource "aws_ses_receipt_rule" "store" {
|
||||
depends_on = ["aws_ses_receipt_rule_set.main"]
|
||||
name = "store-${var.stage}"
|
||||
rule_set_name = "default-rule-set"
|
||||
recipients = ["invoices@mail.integreat.aws.brycecovertoperations.com"]
|
||||
recipients = ["${var.invoice_address}"]
|
||||
enabled = true
|
||||
scan_enabled = true
|
||||
|
||||
s3_action {
|
||||
bucket_name = "${aws_s3_bucket.invoices.id}"
|
||||
position = 0
|
||||
position = "1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +45,7 @@ resource "aws_s3_bucket" "invoices" {
|
||||
"Service": "ses.amazonaws.com"
|
||||
},
|
||||
"Action": "s3:PutObject",
|
||||
"Resource": "arn:aws:s3:::integreat-mail-prod/*",
|
||||
"Resource": "arn:aws:s3:::integreat-mail-${var.stage}/*",
|
||||
"Condition": {
|
||||
"StringEquals": {
|
||||
"aws:Referer": "${data.aws_caller_identity.current.account_id}"
|
||||
@@ -64,7 +67,7 @@ resource "aws_sqs_queue" "integreat-mail" {
|
||||
"Effect": "Allow",
|
||||
"Principal": "*",
|
||||
"Action": "sqs:SendMessage",
|
||||
"Resource": "arn:aws:sqs:*:*:integreat-mail-prod",
|
||||
"Resource": "arn:aws:sqs:*:*:integreat-mail-${var.stage}",
|
||||
"Condition": {
|
||||
"ArnEquals": { "aws:SourceArn": "${aws_s3_bucket.invoices.arn}" }
|
||||
}
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
aws_access_key_id="AKIAINHACMVQJ6NYD26A"
|
||||
aws_secret_access_key="FwdL4TbIC/5H/4mwhQy4iSI/eSewyPgfS1EEt6tL"
|
||||
domain="integreat.aws.brycecovertoperations.com"
|
||||
invoice_address="invoices@mail.integreat.aws.brycecovertoperations.com"
|
||||
base_url="https://integreat.aws.brycecovertoperations.com"
|
||||
stage="prod"
|
||||
|
||||
@@ -46,7 +46,7 @@ EOF
|
||||
resource "aws_sns_topic_subscription" "send_reminders_to_service" {
|
||||
topic_arn = "${aws_sns_topic.reminder_topic.arn}"
|
||||
protocol = "https"
|
||||
endpoint = "https://integreat.aws.brycecovertoperations.com/api/reminders/send"
|
||||
endpoint = "${var.base_url}/api/reminders/send"
|
||||
endpoint_auto_confirms = true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user