(postgres: PostgresNested)
| 15 | { mounts: true; environment: { with: { project: true } } } |
| 16 | >; |
| 17 | export const buildPostgres = async (postgres: PostgresNested) => { |
| 18 | const { |
| 19 | appName, |
| 20 | env, |
| 21 | externalPort, |
| 22 | dockerImage, |
| 23 | memoryLimit, |
| 24 | memoryReservation, |
| 25 | cpuLimit, |
| 26 | cpuReservation, |
| 27 | databaseName, |
| 28 | databaseUser, |
| 29 | databasePassword, |
| 30 | command, |
| 31 | args, |
| 32 | mounts, |
| 33 | } = postgres; |
| 34 | |
| 35 | const defaultPostgresEnv = `POSTGRES_DB="${databaseName}"\nPOSTGRES_USER="${databaseUser}"\nPOSTGRES_PASSWORD="${databasePassword}"${ |
| 36 | env ? `\n${env}` : "" |
| 37 | }`; |
| 38 | |
| 39 | const { |
| 40 | HealthCheck, |
| 41 | RestartPolicy, |
| 42 | Placement, |
| 43 | Labels, |
| 44 | Mode, |
| 45 | RollbackConfig, |
| 46 | UpdateConfig, |
| 47 | Networks, |
| 48 | StopGracePeriod, |
| 49 | EndpointSpec, |
| 50 | Ulimits, |
| 51 | } = generateConfigContainer(postgres); |
| 52 | const resources = calculateResources({ |
| 53 | memoryLimit, |
| 54 | memoryReservation, |
| 55 | cpuLimit, |
| 56 | cpuReservation, |
| 57 | }); |
| 58 | const envVariables = prepareEnvironmentVariables( |
| 59 | defaultPostgresEnv, |
| 60 | postgres.environment.project.env, |
| 61 | postgres.environment.env, |
| 62 | ); |
| 63 | const volumesMount = generateVolumeMounts(mounts); |
| 64 | const bindsMount = generateBindMounts(mounts); |
| 65 | const filesMount = generateFileMounts(appName, postgres); |
| 66 | |
| 67 | const docker = await getRemoteDocker(postgres.serverId); |
| 68 | |
| 69 | const settings: CreateServiceOptions = { |
| 70 | Name: appName, |
| 71 | TaskTemplate: { |
| 72 | ContainerSpec: { |
| 73 | HealthCheck, |
| 74 | Image: dockerImage, |
no test coverage detected