Skip to content

Commit

Permalink
Merge pull request #68 from skni-kod/feature/#67-add-healthcheck-in-d…
Browse files Browse the repository at this point in the history
…ocker-compose-file

added healthcheck in docker-compose
  • Loading branch information
Comply5000 authored Feb 21, 2024
2 parents 8b317bb + cd3eec0 commit df1c7fd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
7 changes: 6 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
services:
api:
image: skitskni/api:latest
depends_on:
depends_on:
- db
ports:
- '5000:80'
Expand All @@ -22,6 +22,11 @@ services:
- postgres-data:/var/lib/postgresql/data
depends_on:
- minio
healthcheck:
test: [ "CMD-SHELL", "pg_isready" ]
interval: 5s
timeout: 5s
retries: 5

minio:
image: minio/minio:latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,17 @@ public S3StorageService(S3Config s3Config)
public async Task<string> UploadFileAsync(IFormFile file, CancellationToken cancellationToken)
{
var uniqueFileName = $"{Guid.NewGuid()}_{file.FileName}";

await using var stream = file.OpenReadStream();
var request = new PutObjectRequest
{
BucketName = _s3Config.BucketName,
Key = uniqueFileName,
InputStream = stream,
ContentType = file.ContentType
};

try
{
await _s3Client.PutObjectAsync(request, cancellationToken);
await using var stream = file.OpenReadStream();
await _s3Client.PutObjectAsync(new PutObjectRequest()
{
BucketName = _s3Config.BucketName,
Key = uniqueFileName,
InputStream = stream,
ContentType = file.ContentType
}, cancellationToken);
}
catch (AmazonS3Exception e)
{
Expand All @@ -50,7 +49,16 @@ public async Task<string> UploadFileAsync(IFormFile file, CancellationToken canc
};
await _s3Client.PutBucketAsync(putBucketRequest, cancellationToken);

await _s3Client.PutObjectAsync(request, cancellationToken);
await using var stream = file.OpenReadStream();
await _s3Client.PutObjectAsync(new PutObjectRequest()
{
BucketName = _s3Config.BucketName,
Key = uniqueFileName,
InputStream = stream,
ContentType = file.ContentType
}, cancellationToken);

return uniqueFileName;
}

throw new S3UploadException(e.ErrorCode);
Expand Down

0 comments on commit df1c7fd

Please sign in to comment.