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

Adding docker compose for app and azurite #27

Merged
merged 2 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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: 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
Loading