test.Dockerfile 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # Copyright 2020 Docker Compose CLI authors
  2. # Licensed under the Apache License, Version 2.0 (the "License");
  3. # you may not use this file except in compliance with the License.
  4. # You may obtain a copy of the License at
  5. # http://www.apache.org/licenses/LICENSE-2.0
  6. # Unless required by applicable law or agreed to in writing, software
  7. # distributed under the License is distributed on an "AS IS" BASIS,
  8. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. # See the License for the specific language governing permissions and
  10. # limitations under the License.
  11. # Distro options: ubuntu, centos
  12. ARG DISTRO=ubuntu
  13. FROM ubuntu:20.04 AS base-ubuntu
  14. RUN apt-get update && apt-get install -y \
  15. curl
  16. RUN curl https://get.docker.com | sh
  17. FROM centos:7 AS base-centos
  18. RUN curl https://get.docker.com | sh
  19. FROM base-${DISTRO} AS install
  20. RUN apt-get update && apt-get -y install sudo
  21. RUN adduser --disabled-password --gecos '' newuser
  22. RUN adduser newuser sudo
  23. RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
  24. USER newuser
  25. WORKDIR /home/newuser
  26. COPY install_linux.sh /scripts/install_linux.sh
  27. RUN sudo chmod +x /scripts/install_linux.sh
  28. ARG DOWNLOAD_URL=
  29. RUN DOWNLOAD_URL=${DOWNLOAD_URL} /scripts/install_linux.sh
  30. RUN docker version | grep Cloud
  31. FROM install AS upgrade
  32. USER newuser
  33. WORKDIR /home/newuser
  34. RUN DOWNLOAD_URL=${DOWNLOAD_URL} /scripts/install_linux.sh
  35. RUN docker version | grep Cloud
  36. # To run this test locally, start an HTTP server that serves the dist/ folder
  37. # then run a docker build passing the DOWNLOAD_URL as a build arg:
  38. # $ cd dist/ && python3 -m http.server &
  39. # $ docker build -f test.Dockerfile --build-arg DOWNLOAD_URL=http://192.168.0.22:8000/docker-linux-amd64.tar.gz .
  40. #
  41. # You can specify centos or ubuntu as distros using the DISTRO build arg.