aboutsummaryrefslogtreecommitdiffstats
path: root/ci/build.yml
blob: 7d517094159d1ac6c1c44ca4361275361de9c5ad (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
steps:
  - task: ShellScript@2
    displayName: 'Check If Images Need to Be Built'
    inputs:
      scriptPath: scripts/check_dockerfiles.sh
      disableAutoCwd: true

  # Without a login, the following Docker build steps wouldn't add image tags.
  - task: Docker@1
    displayName: 'Log into Docker Hub'
    inputs:
      command: login
      containerregistrytype: 'Container Registry'
      dockerRegistryEndpoint: 'DockerHub'

  # Building the venv depends on this base image. Build the base if it can't
  # pulled from Docker Hub, which will be the case if the base Dockerfile has
  # has had changes.
  - script: |
      docker build \
        -f docker/base.Dockerfile \
        -t pythondiscord/snekbox-base:latest \
        .
    displayName: 'Build Base Image'
    condition: >
      and(
        succeeded(),
        or(
          eq(variables.BASE_CHANGED, 'True'),
          and(
            eq(variables.VENV_CHANGED, 'True'),
            eq(variables.BASE_PULL, 'False')
          )
        )
      )

  # Build the venv image if it's had changes or it can't be pulled.
  - script: |
      docker build \
        -f docker/venv.Dockerfile \
        -t pythondiscord/snekbox-venv:latest \
        .
    displayName: 'Build Virtual Environment Image'
    condition: >
      and(
        succeeded(),
        or(
          eq(variables.VENV_CHANGED, 'True'),
          eq(variables.VENV_PULL, 'False')
        )
      )