@ossy/deployment-tools 0.0.76 → 0.0.77

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ossy/deployment-tools",
3
- "version": "0.0.76",
3
+ "version": "0.0.77",
4
4
  "description": "Collection of scripts and tools to aid deployment of containers and static files to Amazon Web Services through GitHub Actions",
5
5
  "source": "./src/index.js",
6
6
  "main": "./src/index.js",
@@ -16,22 +16,29 @@ class DockerService {
16
16
 
17
17
  static startDefaultContainers(platformConfig) {
18
18
  return exec(`docker run -d --name=mongodb --network=${platformConfig.ciDockerNetworkName} --network-alias=mongodb --rm mongo`)
19
- .catch(logErrorAndReject('[DockerService] Could not start mongodb container'))
19
+ .catch(() => {/* if it fails it's probably because the network already exists*/})
20
20
  }
21
21
 
22
22
  static createDockerNetworkForContainerManagerServer(platformConfig) {
23
23
  logInfo({ message: '[DockerService] Creating docker network for comunication between containers' })
24
24
  return exec(`docker network create ${platformConfig.ciDockerNetworkName}`)
25
- .catch(() => {/* if it fils it's probably because the network already exists*/})
25
+ .catch(() => {/* if it fails it's probably because the network already exists*/ })
26
26
  }
27
27
 
28
28
  static stopContainer(deploymentRequest) {
29
29
  const name = deploymentRequest.image.replaceAll('/', '_')
30
- logInfo({ message: `[DockerService] Running docker stop for image with the name of ${name}` })
30
+ logInfo({ message: `[DockerService] Stopping container for ${name}` })
31
31
  return exec(`docker stop ${name}`)
32
32
  .catch(() => {}) // no worries if container isn't there
33
33
  }
34
34
 
35
+ static removeImage(deploymentRequest) {
36
+ const name = deploymentRequest.image.replaceAll('/', '_')
37
+ logInfo({ message: `[DockerService] Removing image ${name}` })
38
+ return exec(`docker image rm -f ${name}`)
39
+ .catch(() => {}) // no worries if container isn't there
40
+ }
41
+
35
42
  static startContainer(platformConfig, { image, containerPort, hostPort, registry, env }) {
36
43
  const name = image.replaceAll('/', '_')
37
44
  const imageUrl = !!registry ? `${registry}/${image}` : image
@@ -60,6 +67,7 @@ class DockerService {
60
67
 
61
68
  return DockerService.resolveCredentials(deploymentRequest)
62
69
  .then(() => DockerService.stopContainer(deploymentRequest))
70
+ .then(() => DockerService.removeImage(deploymentRequest))
63
71
  .then(() => DockerService.startContainer(platformConfig, deploymentRequest))
64
72
  }
65
73
 
@@ -1,19 +1,4 @@
1
1
  const { DockerService } = require('./docker-service')
2
2
 
3
- // DockerService.deploy(
4
- // { ciDockerNetworkName: 'deployment-tools' },
5
- // {
6
- // type: 'CONTAINER',
7
- // dockerFile: './Dockerfile-prod',
8
- // dockerContext: './',
9
- // targetDeploymentPlatform: 'oskarssylwan',
10
- // image: 'mongo',
11
- // hostPort: '3005',
12
- // containerPort: '3000',
13
- // subdomain: 'cms',
14
- // env: {},
15
- // registry: 'ghcr.io'
16
- // }
17
- // )
18
3
 
19
- DockerService.createDockerNetworkForContainerManagerServer({ ciDockerNetworkName: 'foo' })
4
+ DockerService.removeImage({ ciDockerNetworkName: 'foo', image: 'mongo' })
@@ -52,7 +52,8 @@ class DnsStack extends Stack {
52
52
  new ARecord(this, domain, {
53
53
  zone,
54
54
  recordName: domain,
55
- target: RecordTarget.fromIpAddresses(props.containerDeploymentTargetPublicIp)
55
+ target: RecordTarget.fromIpAddresses(props.containerDeploymentTargetPublicIp),
56
+ ttl: Duration.seconds(60)
56
57
  })
57
58
  })
58
59