test.Dockerfile 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. RUN sh -c "docker info || true" | grep "compose: Docker Compose (Docker Inc.,"
  32. FROM install AS upgrade
  33. USER newuser
  34. WORKDIR /home/newuser
  35. RUN DOWNLOAD_URL=${DOWNLOAD_URL} /scripts/install_linux.sh
  36. RUN docker version | grep Cloud
  37. RUN sh -c "docker info || true" | grep "compose: Docker Compose (Docker Inc.,"
  38. # To run this test locally, start an HTTP server that serves the dist/ folder
  39. # then run a docker build passing the DOWNLOAD_URL as a build arg:
  40. # $ cd dist/ && python3 -m http.server &
  41. # $ docker build -f test.Dockerfile --build-arg DOWNLOAD_URL=http://192.168.0.22:8000/docker-linux-amd64.tar.gz .
  42. #
  43. # You can specify centos or ubuntu as distros using the DISTRO build arg.