Skip to content
This repository has been archived by the owner on Feb 7, 2025. It is now read-only.

Commit

Permalink
Adding docker compose for app and azurite (#27)
Browse files Browse the repository at this point in the history
* Adding docker compose for app and azurite

* Update README.md

---------

Co-authored-by: jcrichlake <[email protected]>
  • Loading branch information
somesylvie and jcrichlake authored May 21, 2024
1 parent 1e7557b commit 8213917
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ reportstream-sftp-ingestion
# Ignore terraform state (as it is persisted via Azure Storage)
terraform.tfstate*
.terraform*

# Local blob storage data
/localdata
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,9 @@ pre-commit install
```

### Running locally
For the Azure blob storage modify and run the below command to spin up Azurite which will run blob storage locally


```shell
azurite --silent --location ~/AzuritelocationOnYourMachine --debug ~/location/for/logs/debug.log
```
Run `docker-compose`, which will spin up both an Azurite container and the app. By default, this leaves the ReportStream
URL prefix environment variable empty, and we'll use a mock response rather than calling ReportStream. Uncomment
the `REPORT_STREAM_URL_PREFIX` in [docker-compose.yml](docker-compose.yml) to call locally-running ReportStream instead.

### Testing

Expand Down
34 changes: 34 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: "3.7"
services:
rs-sftp:
build: .
environment:
AZURE_BLOB_CONNECTION_STRING: DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://sftp-Azurite:10000/devstoreaccount1;
ENV: local
# Uncomment the line below to call local report stream. Otherwise we'll use a mock response
#REPORT_STREAM_URL_PREFIX: http://localhost:7071
ports:
- "9090:9090" # default api endpoint port
platform: linux/amd64
depends_on:
- sftp-Azurite
networks:
- sftp

sftp-Azurite:
image: mcr.microsoft.com/azure-storage/azurite
# uncomment the line below to skip x-ms-version checks
# command: azurite --skipApiVersionCheck --blobHost 0.0.0.0 --queueHost 0.0.0.0
volumes:
# map to Azurite data objects to the build directory
- ./localdata/azurite:/data
ports:
- "11000:10000"
- "11001:10001"
- "11002:10002"
networks:
- sftp


networks:
sftp:
20 changes: 14 additions & 6 deletions src/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,21 @@ func main() {
}

reportStreamBaseUrl := os.Getenv("REPORT_STREAM_URL_PREFIX")
apiHandler := report_stream.ApiHandler{BaseUrl: reportStreamBaseUrl}
reportId, err := apiHandler.SendReport(content)
if err != nil {
slog.Error("Failed to send the file to ReportStream", slog.Any("error", err))
os.Exit(1)

if reportStreamBaseUrl == "" {
// Do something with mock response

slog.Info("Mock message sent to Mock RS.")
} else {
apiHandler := report_stream.ApiHandler{BaseUrl: reportStreamBaseUrl}
reportId, err := apiHandler.SendReport(content)

if err != nil {
slog.Error("Failed to send the file to ReportStream", slog.Any("error", err))
os.Exit(1)
}
slog.Info("File sent to ReportStream", slog.String("reportId", reportId))
}
slog.Info("File sent to ReportStream", slog.String("reportId", reportId))

for {
t := time.Now()
Expand Down

0 comments on commit 8213917

Please sign in to comment.