Skip to content

Commit

Permalink
docker: use single parameterized Dockerfile for all images
Browse files Browse the repository at this point in the history
Signed-off-by: Anatoli Babenia <anatoli@rainforce.org>
  • Loading branch information
abitrolly committed Jan 2, 2020
1 parent 2252dd7 commit a6c0f5a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 147 deletions.
8 changes: 6 additions & 2 deletions docker/beta.Dockerfile → docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
ARG RISK=edge

FROM ubuntu:xenial as builder

RUN echo "Building snapcraft:$RISK"

# Grab dependencies
RUN apt-get update
RUN apt-get dist-upgrade --yes
Expand All @@ -13,8 +17,8 @@ RUN curl -L $(curl -H 'X-Ubuntu-Series: 16' 'https://api.snapcraft.io/api/v1/sna
RUN mkdir -p /snap/core
RUN unsquashfs -d /snap/core/current core.snap

# Grab the snapcraft snap from the beta channel and unpack it in the proper place
RUN curl -L $(curl -H 'X-Ubuntu-Series: 16' 'https://api.snapcraft.io/api/v1/snaps/details/snapcraft?channel=beta' | jq '.download_url' -r) --output snapcraft.snap
# Grab the snapcraft snap from the $RISK channel and unpack it in the proper place
RUN curl -L $(curl -H 'X-Ubuntu-Series: 16' 'https://api.snapcraft.io/api/v1/snaps/details/snapcraft?channel='$RISK | jq '.download_url' -r) --output snapcraft.snap
RUN mkdir -p /snap/snapcraft
RUN unsquashfs -d /snap/snapcraft/current snapcraft.snap

Expand Down
20 changes: 10 additions & 10 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ like `--dns=8.8.8.8` added to the command.

## Creating containers

There are four separate Dockerfiles here, each one corresponding to their
respective risk level:
The Dockerfile here can build images for these risk levels:

- **edge.Dockerfile**: Using the snap from edge
- **beta.Dockerfile**: Using the snap from beta
- **candidate.Dockerfile**: Using the snap from candidate
- **stable.Dockerfile**: Using the snap from stable
- **edge**: Using the snap from edge
- **beta**: Using the snap from beta
- **candidate**: Using the snap from candidate
- **stable**: Using the snap from stable

Build the docker image with the following (note that `--network host` is not
strictly needed if a proper docker bridge is setup):
By default, the `edge` image will be built. Pass `--build-arg RISK=<risk>` to
choose needed risk level for target container:

docker build --no-cache -f <risk>.Dockerfile --label snapcore/snapcraft --tag snapcore/snapcraft:<risk> --network host .
export RISK=beta
docker build --no-cache --tag snapcore/snapcraft:$RISK --build-arg RISK=$RISK .

You can push that image with:

docker push snapcore/snapcraft:<risk>
docker push snapcore/snapcraft:$RISK
45 changes: 0 additions & 45 deletions docker/candidate.Dockerfile

This file was deleted.

45 changes: 0 additions & 45 deletions docker/edge.Dockerfile

This file was deleted.

45 changes: 0 additions & 45 deletions docker/stable.Dockerfile

This file was deleted.

0 comments on commit a6c0f5a

Please sign in to comment.