Skip to content

Commit

Permalink
fix compose
Browse files Browse the repository at this point in the history
  • Loading branch information
mucsi96 committed Aug 22, 2024
1 parent 6ec419c commit d002779
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ VOLUME /tmp

ARG DEPENDENCY=/workspace/server/target/dependency

RUN apk add postgresql15-client
RUN apk add postgresql16-client

COPY --from=build-server ${DEPENDENCY}/BOOT-INF/lib /app/lib
COPY --from=build-server ${DEPENDENCY}/META-INF /app/META-INF
Expand Down
10 changes: 9 additions & 1 deletion docker-compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ const config = {
POSTGRES_DB,
POSTGRES_PASSWORD,
POSTGRES_USER,
BLOBSTORAGE_ENDPOINT_URL: "http://blobstorage:10000",
BLOBSTORAGE_CONNECTION_STRING: Object.entries({
DefaultEndpointsProtocol: "http",
AccountName: "devstoreaccount1",
AccountKey:
"Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==",
BlobEndpoint: "http://blobstorage:10000/devstoreaccount1",
})
.map(([key, value]) => `${key}=${value}`)
.join(";"),
BLOBSTORAGE_CONTAINER: "test-bucket",
EXCLUDE_TABLES: "passwords,secrets",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

import com.azure.core.credential.TokenCredential;
import com.azure.identity.DefaultAzureCredentialBuilder;
Expand All @@ -16,10 +15,16 @@
@Configuration
public class BackupConfiguration {

@Profile("!test")
@Bean
public BlobServiceClient blobServiceClient(
@Value("${blobstorage.endpoint}") String endpointUrl) {
@Value("${blobstorage.endpoint}") String endpointUrl,
@Value("${blobstorage.connectionString}") String connectionString) {

if (connectionString != null && !connectionString.isEmpty()) {
return new BlobServiceClientBuilder().connectionString(connectionString)
.buildClient();
}

TokenCredential tokenCredential = new DefaultAzureCredentialBuilder()
.build();

Expand All @@ -29,16 +34,6 @@ public BlobServiceClient blobServiceClient(
return blobServiceClient;
}

@Profile("test")
@Bean
public BlobServiceClient mockBlobServiceClient(
@Value("${blobstorage.connectionString}") String connectionString) {
BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
.connectionString(connectionString).buildClient();

return blobServiceClient;
}

@Bean
public DateTimeFormatter backupDateTimeFormat() {
return DateTimeFormatter.ofPattern("yyyyMMdd-HHmmss")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ public File createDump(int retentionPeriod)

System.out.println("Creating dump: " + String.join(", ", commands));

new ProcessBuilder(commands).inheritIO().start().waitFor();
int status = new ProcessBuilder(commands).inheritIO().start().waitFor();

if (status != 0) {
throw new RuntimeException("Unable to create dump. pg_dump failed");
}

File file = new File(filename);

Expand Down
3 changes: 2 additions & 1 deletion server/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
blobstorage:
endpoint: ${BLOBSTORAGE_ENDPOINT_URL}
endpoint: ${BLOBSTORAGE_ENDPOINT_URL:''}
connectionString: ${BLOBSTORAGE_CONNECTION_STRING:''}
container: ${BLOBSTORAGE_CONTAINER}

postgres:
Expand Down

0 comments on commit d002779

Please sign in to comment.