Skip to content

Commit

Permalink
Build epicli image using Dockerfile only (#1614)
Browse files Browse the repository at this point in the history
  • Loading branch information
to-bar authored Sep 3, 2020
1 parent f4a5263 commit 643c5dc
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 115 deletions.
28 changes: 13 additions & 15 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# Ignore all unwanted files from the docker build process

.git
.git*
*.log
certs/
**/data/*

*.md

tests/
Dockerfile

core/data/
core/build/
# Exclude unnecessary files from the build context
# This file is meant to be used as a whitelist

# Exclude everything
*

# Include the following
!README.md
!LICENSE
!core/src/epicli/.devcontainer/requirements.txt
!core/src/epicli/cli/
!core/src/epicli/data/
!core/src/epicli/setup.py
3 changes: 2 additions & 1 deletion CHANGELOG-0.8.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
## [0.8.0] 2020-09-xx

### Added
- [#1324](https://github.com/epiphany-platform/epiphany/issues/1324) - Added Logstash to export data from Elasticsearch to csv format

- [#1324](https://github.com/epiphany-platform/epiphany/issues/1324) - Added Logstash to export data from Elasticsearch to csv format
- [#1300](https://github.com/epiphany-platform/epiphany/issues/1300) - Configure OpenSSH according to Mozilla Infosec guidance
- [#1543](https://github.com/epiphany-platform/epiphany/issues/1543) - Add support for Azure availability sets
- [#1609](https://github.com/epiphany-platform/epiphany/issues/1609) - Build epicli image using Dockerfile only (without shell script)

### Updated

Expand Down
47 changes: 47 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# === Build epicli wheel file ===

FROM python:3.7-slim AS build-epicli-wheel

COPY . /src
WORKDIR /src/core/src/epicli

RUN python setup.py bdist_wheel

# === Build final image ===

FROM python:3.7-slim

ARG USERNAME=epiuser
ARG USER_UID=1000
ARG USER_GID=$USER_UID

ENV EPICLI_DOCKER_SHARED_DIR=/shared

COPY --from=build-epicli-wheel /src/core/src/epicli/dist/ /epicli/

RUN apt-get update \
&& apt-get install --no-install-recommends -y \
gcc libffi-dev make musl-dev openssh-client ruby-full sudo tar unzip vim \
&& gem install \
rake rspec_junit_formatter serverspec \
&& pip install --disable-pip-version-check --no-cache-dir \
/epicli/epicli-*-py3-none-any.whl \
\
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* \
\
&& groupadd --gid $USER_GID $USERNAME \
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME \
\
&& mkdir -p $EPICLI_DOCKER_SHARED_DIR \
&& chown $USERNAME $EPICLI_DOCKER_SHARED_DIR \
&& chmod g+w $EPICLI_DOCKER_SHARED_DIR

WORKDIR $EPICLI_DOCKER_SHARED_DIR

USER $USERNAME

ENTRYPOINT ["/bin/bash"]
41 changes: 21 additions & 20 deletions core/src/epicli/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,32 @@ COPY requirements.txt /

RUN chmod +x /config-pre.sh \
&& /bin/bash -c /config-pre.sh \

\
&& apt-get update \
&& apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \

&& apt-get -y install git git-lfs procps lsb-release gcc make musl-dev libffi-dev tar unzip vim \

&& apt-get -y install ruby-full \

&& gem install serverspec rake rspec_junit_formatter \

&& pip --disable-pip-version-check --no-cache-dir install -r /requirements.txt --default-timeout=100 \

&& pip --disable-pip-version-check --no-cache-dir install pipenv pylint pytest wheel setuptools twine --default-timeout=100 \

&& apt-get install --no-install-recommends -y \
apt-utils dialog 2>&1 \
&& apt-get install --no-install-recommends -y \
gcc libffi-dev make musl-dev openssh-client ruby-full sudo tar unzip vim \
\
git git-lfs lsb-release procps \
\
&& gem install \
rake rspec_junit_formatter serverspec \
\
&& pip install --disable-pip-version-check --no-cache-dir --default-timeout=100 \
--requirement /requirements.txt \
&& pip install --disable-pip-version-check --no-cache-dir --default-timeout=100 \
pipenv pylint pytest setuptools twine wheel \
\
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* \
\
&& groupadd --gid $USER_GID $USERNAME \
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \

&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME \

&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* \

\
&& chmod +x /config-post.sh \
&& /bin/bash -c /config-post.sh

Expand Down
37 changes: 0 additions & 37 deletions core/src/epicli/Dockerfile

This file was deleted.

5 changes: 0 additions & 5 deletions core/src/epicli/build-docker.bat

This file was deleted.

5 changes: 0 additions & 5 deletions core/src/epicli/build-docker.sh

This file was deleted.

43 changes: 11 additions & 32 deletions docs/home/howto/PREREQUISITES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,59 +6,38 @@ There are 2 ways to get the image, build it locally yourself or pull it from the

1. Install the following dependencies:

- Python 3.7
- PIP
- Docker

2. Install the following Python dependencies using PIP:
2. Open a terminal in the root directory of the Epiphany source code and run:

```bash
pip install wheel setuptools twine
```

3. Open a terminal in `/core/src/epicli` and run:

On Linux/Mac:

```bash
./build-docker.sh debian|alpine
```

On windows:

```bash
./build-docker.bat debian|alpine
```
```bash
TAG=$(cat core/src/epicli/cli/version.txt.py)
docker build --file Dockerfile --tag epicli:${TAG} .
```

*Note: Use the debian or alpine flag to indicate which base image you want to use for the Epicli container.*

### Pull Epicli image from the registry

```bash
docker pull epiphanyplatform/epicli:TAG
```

Where `TAG` should be replaced with an existing tag.

*Check [here](https://cloud.docker.com/u/epiphanyplatform/repository/docker/epiphanyplatform/epicli) for the available tags.*

### Running the Epicli image

To run the image:

Locally build:

```bash
docker run -it -v LOCAL_DIR:/shared --rm epicli
```

Pulled:

```bash
docker run -it -v LOCAL_DIR:/shared --rm epiphanyplatform/epicli:TAG
```

*Check [here](https://cloud.docker.com/u/epiphanyplatform/repository/docker/epiphanyplatform/epicli) for the available tags.*
Where:
- `LOCAL_DIR` should be replaced with the local path to the directory for Epicli input (SSH keys, data yamls) and output (logs, build states),
- `TAG` should be replaced with an existing tag.

Where `LOCAL_DIR` should be replaced with the local path to the directory for Epicli input (SSH keys, data yamls) and output (logs, build states).
*Check [here](https://cloud.docker.com/u/epiphanyplatform/repository/docker/epiphanyplatform/epicli) for the available tags.*

## Epicli development

Expand Down

0 comments on commit 643c5dc

Please sign in to comment.