Skip to content

Commit 5ba30ba

Browse files
authored
Merge pull request #92 from joshuanianji/fix-test
Deprecate ubuntu and debian images
2 parents d830f64 + 1c1f794 commit 5ba30ba

13 files changed

+105
-244
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"features": {
3+
"ghcr.io/devcontainers/features/common-utils:2": {
4+
"version": "2.5.3",
5+
"resolved": "ghcr.io/devcontainers/features/common-utils@sha256:3cf7ca93154faf9bdb128f3009cf1d1a91750ec97cc52082cf5d4edef5451f85",
6+
"integrity": "sha256:3cf7ca93154faf9bdb128f3009cf1d1a91750ec97cc52082cf5d4edef5451f85"
7+
},
8+
"ghcr.io/devcontainers/features/docker-in-docker:2": {
9+
"version": "2.12.2",
10+
"resolved": "ghcr.io/devcontainers/features/docker-in-docker@sha256:842d2ed40827dc91b95ef727771e170b0e52272404f00dba063cee94eafac4bb",
11+
"integrity": "sha256:842d2ed40827dc91b95ef727771e170b0e52272404f00dba063cee94eafac4bb"
12+
},
13+
"ghcr.io/devcontainers/features/github-cli:1": {
14+
"version": "1.0.14",
15+
"resolved": "ghcr.io/devcontainers/features/github-cli@sha256:ca677566507c4118e4368cd76a4800807e911e5e350cc3525fb67ebc9132dfa1",
16+
"integrity": "sha256:ca677566507c4118e4368cd76a4800807e911e5e350cc3525fb67ebc9132dfa1"
17+
},
18+
"ghcr.io/edouard-lopez/devcontainer-features/bats:0": {
19+
"version": "0.0.1",
20+
"resolved": "ghcr.io/edouard-lopez/devcontainer-features/bats@sha256:8acd020fc45ebacdd399a29977c4d22cad56b5c95c43cdf2ae061f0e755aea7a",
21+
"integrity": "sha256:8acd020fc45ebacdd399a29977c4d22cad56b5c95c43cdf2ae061f0e755aea7a"
22+
},
23+
"ghcr.io/joshuanianji/devcontainer-features/github-cli-persistence:1": {
24+
"version": "1.0.3",
25+
"resolved": "ghcr.io/joshuanianji/devcontainer-features/github-cli-persistence@sha256:757843d75915f140ec22bc16ccb5e657a910d9b1d1f445d15350a78e584d130f",
26+
"integrity": "sha256:757843d75915f140ec22bc16ccb5e657a910d9b1d1f445d15350a78e584d130f"
27+
}
28+
}
29+
}
File renamed without changes.

.github/workflows/version-base-build-test.yml

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -104,73 +104,3 @@ jobs:
104104
run: |
105105
docker run ${{ env.TAG }} /bin/bash -c "make test"
106106
107-
# "consumer" images just "consume" the base image and do nothing else
108-
# basic tests for these
109-
consumer-build-test:
110-
name: Build Consumer
111-
runs-on: ubuntu-latest
112-
needs: [base-test-1, base-test-2]
113-
strategy:
114-
matrix:
115-
dockerfile: [debian, ubuntu]
116-
# use a local registry
117-
services:
118-
registry:
119-
image: registry:2
120-
ports:
121-
- 5000:5000
122-
env:
123-
# use local registry so we can reference the base image in another dockerfile
124-
# https://github.com/docker/build-push-action/issues/738
125-
BASE_TAG: localhost:5000/base-${{ inputs.idris-version }}:latest
126-
TAG: idris-consumer-${{ matrix.dockerfile }}-${{ inputs.idris-version }}:test
127-
steps:
128-
- name: Checkout Repo
129-
uses: actions/checkout@v4
130-
131-
- name: Setup Buildx (no ARM)
132-
uses: docker/setup-buildx-action@v3
133-
with:
134-
# since we're using a local registry
135-
driver-opts: network=host
136-
137-
- name: Build Base Image
138-
uses: ./.github/actions/build-base-img
139-
with:
140-
idris-version: ${{ inputs.idris-version }}
141-
push: true
142-
tags: ${{ env.BASE_TAG }}
143-
144-
- name: Run `docker image ls`
145-
run: docker image ls
146-
147-
- name: Build ${{ matrix.dockerfile}}
148-
uses: docker/build-push-action@v6
149-
with:
150-
context: .
151-
file: ${{ matrix.dockerfile }}.Dockerfile
152-
build-args: |
153-
IDRIS_VERSION=${{ inputs.idris-version }}
154-
BASE_IMG=${{ env.BASE_TAG }}
155-
tags: ${{ env.TAG }}
156-
load: true
157-
158-
- name: Setup Bats and Bats libs
159-
uses: bats-core/[email protected]
160-
with:
161-
bats-version: 1.10.0
162-
support-version: 0.3.0
163-
support-path: ${{ github.workspace }}/.bats/bats-support
164-
assert-version: 2.1.0
165-
assert-path: ${{ github.workspace }}/.bats/bats-assert
166-
file-install: false
167-
detik-install: false
168-
169-
# LIB_PATH is a env var I use in the setup() function of my bats tests
170-
# it points to the folder containing bats-assert and bats-support
171-
- name: Run Test
172-
env:
173-
LIB_PATH: ${{ github.workspace }}/.bats
174-
DOCKER_IMAGE: ${{ env.TAG }}
175-
IDRIS_VERSION: ${{ inputs.idris-version }}
176-
run: bats tests/consumer-idris.bats

.github/workflows/version-base-deploy.yml

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -54,46 +54,3 @@ jobs:
5454
labels: ${{ steps.create-meta.outputs.labels }}
5555
platforms: linux/amd64,linux/arm64
5656

57-
deploy-consumers:
58-
name: Deploy Consumer
59-
runs-on: ubuntu-latest
60-
strategy:
61-
matrix:
62-
dockerfile: [ubuntu, debian]
63-
needs: deploy-base
64-
steps:
65-
- name: Checkout Repo
66-
uses: actions/checkout@v4
67-
68-
# instead of native builds, we'll just use QEMU for consumers
69-
# consumer builds don't really do much intensive stuff anyway
70-
- name: Set up QEMU
71-
uses: docker/setup-qemu-action@v3
72-
73-
- name: Setup Buildx
74-
uses: docker/setup-buildx-action@v3
75-
76-
- name: Login to GHCR
77-
uses: docker/login-action@v3
78-
with:
79-
registry: ghcr.io
80-
username: ${{ github.actor }}
81-
password: ${{ secrets.GITHUB_TOKEN }}
82-
83-
- name: Docker meta
84-
id: create-meta
85-
uses: docker/metadata-action@v5
86-
with:
87-
images: ${{ github.repository }}/${{ matrix.dockerfile }}
88-
89-
- name: Build ${{ matrix.dockerfile}}
90-
uses: docker/build-push-action@v6
91-
with:
92-
context: .
93-
platforms: linux/amd64,linux/arm64
94-
file: ${{ matrix.dockerfile }}.Dockerfile
95-
build-args: |
96-
IDRIS_VERSION=${{ inputs.idris-version }}
97-
BASE_IMG=ghcr.io/${{ github.repository }}/base:${{ inputs.idris-version }}
98-
tags: ghcr.io/${{ github.repository }}/${{ matrix.dockerfile }}:${{ inputs.idris-version }}
99-
push: true

README.md

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Idris Versions: `v0.5.1`, `v0.6.0`, `v0.7.0`, `latest` (Up to date with [Idris2/
2020
- [Running Locally](#running-locally)
2121
- [Build Latest](#build-latest)
2222
- [Build From a Tagged Release/SHA commit](#build-from-a-tagged-releasesha-commit)
23+
- [Running tests](#running-tests)
2324
- [Credit](#credit)
2425

2526
## Motivation
@@ -28,10 +29,8 @@ Installing Idris2 is [quite time consuming](https://idris2.readthedocs.io/en/lat
2829

2930
## Images
3031

31-
* [idris-2-docker/base](https://github.com/joshuanianji/idris-2-docker/pkgs/container/idris-2-docker%2Fbase) - Base image with Idris2 installed from source.
32+
* [idris-2-docker/base](https://github.com/joshuanianji/idris-2-docker/pkgs/container/idris-2-docker%2Fbase) - Base image with Idris2 installed from source (debian-based)
3233
* [idris-2-docker/devcontainer](https://github.com/joshuanianji/idris-2-docker/pkgs/container/idris-2-docker%2Fdevcontainer) - Includes [Idris2 LSP](https://github.com/idris-community/idris2-lsp)
33-
* [idris-2-docker/ubuntu](https://github.com/joshuanianji/idris-2-docker/pkgs/container/idris-2-docker%2Fubuntu) - Ubuntu 20.04
34-
* [idris-2-docker/debian](https://github.com/joshuanianji/idris-2-docker/pkgs/container/idris-2-docker%2Fdebian) - Debian bullseye
3534

3635
## Example Project
3736

@@ -86,17 +85,41 @@ To run the images locally, I recommend opening the workspace in the Devcontainer
8685
This is the default behaviour when running the script.
8786

8887
```bash
88+
# this is the only module we need, so i chose not to create a requirements.txt file
89+
pip install -U requests
90+
8991
# builds base from latest commit on the Idris repo. Tag is base-latest
9092
python scripts/build-image.py --image base
91-
python scripts/build-image.py --image devcontainer --tag devcontainer-latest-test
93+
python scripts/build-image.py --image ubuntu
94+
python scripts/build-image.py --image devcontainer --tag devcontainer-latest
9295
```
9396

9497
### Build From a Tagged Release/SHA commit
9598

9699
```bash
97-
python scripts/build-image.py --image base --version v0.6.0
100+
python scripts/build-image.py --image base --version v0.7.0
98101
python scripts/build-image.py --image base --sha 58e5d156621cfdd4c54df26abf7ac9620cfebdd8
99-
python scripts/build-image.py --image devcontainer --version v0.6.0
102+
python scripts/build-image.py --image devcontainer --version v0.7.0
103+
```
104+
105+
### Running tests
106+
107+
We have some tests to ensure the docker images are working as expected, using [bats](https://github.com/bats-core/bats-core). The bats CLI tool should already be installed in the devcontainer.
108+
109+
You'll need to install the `bats-support` and `bats-assert` libraries. I found the easiest way to do this was to clone via git:
110+
111+
```bash
112+
git clone https://github.com/bats-core/bats-support test/test_helper/bats-support
113+
git clone https://github.com/bats-core/bats-assert test/test_helper/bats-assert
114+
```
115+
116+
To run a test on a specific image, set the required variables, and run the bats command. The following is an example for the base image
117+
118+
```bash
119+
export LIB_PATH=$(pwd)/tests/test_helper
120+
export DOCKER_IMAGE=
121+
export IDRIS_VERSION=latest
122+
bats tests/base.bats
100123
```
101124

102125
## Credit

base-sha.Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# separating this into a separate file so we can get better caching
44
# there is a lot of redundancy between this and base.Dockerfile, but I don't think it's worth it to try to abstract it out
55

6-
FROM debian:bullseye as scheme-builder
6+
FROM debian:bullseye AS scheme-builder
77

88
WORKDIR /root
99

@@ -22,12 +22,12 @@ RUN which scheme
2222
# this makes it a bit easier for us to move the csv folder to other build steps, since it is necessary for scheme to run
2323
RUN mkdir scheme-lib && cp -r /usr/lib/csv* /root/scheme-lib
2424

25-
FROM debian:bullseye as idris-builder
25+
FROM debian:bullseye AS idris-builder
2626

2727
RUN apt-get update && \
2828
apt-get install -y git make gcc libgmp-dev curl
2929

30-
ENV DEBIAN_FRONTEND noninteractive
30+
ENV DEBIAN_FRONTEND=noninteractive
3131
# SHA of the latest commit on the idris-lang/idris2 repo
3232
ARG IDRIS_SHA
3333

base.Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Expects IDRIS_VERSION to NOT be `latest`
2-
# uBut a tag of the form `v0.7.0`
2+
# But a tag of the form `v0.7.0`
33

4-
FROM debian:bullseye as scheme-builder
4+
FROM debian:bullseye AS scheme-builder
55

66
WORKDIR /root
77

@@ -20,12 +20,12 @@ RUN which scheme
2020
# this makes it a bit easier for us to move the csv folder to other build steps, since it is necessary for scheme to run
2121
RUN mkdir scheme-lib && cp -r /usr/lib/csv* /root/scheme-lib
2222

23-
FROM debian:bullseye as idris-builder
23+
FROM debian:bullseye AS idris-builder
2424

2525
RUN apt-get update && \
2626
apt-get install -y git make gcc libgmp-dev curl
2727

28-
ENV DEBIAN_FRONTEND noninteractive
28+
ENV DEBIAN_FRONTEND=noninteractive
2929
ARG IDRIS_VERSION
3030

3131
COPY --from=scheme-builder /usr/bin/scheme /usr/bin/scheme

debian.Dockerfile

Lines changed: 0 additions & 17 deletions
This file was deleted.

devcontainer-sha.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ARG BASE_IMG=ghcr.io/joshuanianji/idris-2-docker/base:${IDRIS_VERSION}
77
# =====
88
# Idris Builder
99
# Rebuild with correct prefix. Somehow, building from scratch with a different prefix fails
10-
FROM $BASE_IMG as idris-builder
10+
FROM $BASE_IMG AS idris-builder
1111
ARG IDRIS_VERSION
1212
ARG IDRIS_SHA
1313

devcontainer.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ARG BASE_IMG=ghcr.io/joshuanianji/idris-2-docker/base:${IDRIS_VERSION}
66
# =====
77
# Idris Builder
88
# Rebuild with correct prefix. Somehow, building from scratch with a different prefix fails
9-
FROM $BASE_IMG as idris-builder
9+
FROM $BASE_IMG AS idris-builder
1010
ARG IDRIS_VERSION
1111

1212
WORKDIR /build

0 commit comments

Comments
 (0)