From 8299da91fb548d2777645c6f83984d5bd791d8d3 Mon Sep 17 00:00:00 2001 From: levgorbunov1 Date: Wed, 10 Jan 2024 13:47:57 +0000 Subject: [PATCH 1/2] Dockerfile building and pushing --- .devcontainer/base_image/Dockerfile | 67 +++++++++++++++++++ .../base_image/build_and_push_to_dockerhub.sh | 9 +++ .devcontainer/devcontainer.json | 20 ++++++ README.md | 20 +++++- 4 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/base_image/Dockerfile create mode 100644 .devcontainer/base_image/build_and_push_to_dockerhub.sh create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/base_image/Dockerfile b/.devcontainer/base_image/Dockerfile new file mode 100644 index 0000000..c113e10 --- /dev/null +++ b/.devcontainer/base_image/Dockerfile @@ -0,0 +1,67 @@ +FROM --platform=linux/amd64 ubuntu:22.04 + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +ENV DEBIAN_FRONTEND noninteractive + +# install some essential tooling +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + gnupg \ + curl \ + software-properties-common \ + git-all \ + less \ + tar \ + unzip \ + zip \ + ca-certificates \ + sudo \ + nodejs \ + jq \ + wget \ + build-essential \ + gpg-agent \ + openssh-client + +# install terraform +RUN wget -O- https://apt.releases.hashicorp.com/gpg | \ + gpg --dearmor | \ + sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg \ + && gpg --no-default-keyring \ + --keyring /usr/share/keyrings/hashicorp-archive-keyring.gpg \ + --fingerprint \ + && echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] \ + https://apt.releases.hashicorp.com $(lsb_release -cs) main" | \ + tee /etc/apt/sources.list.d/hashicorp.list \ + && sudo apt update \ + && sudo apt-get install terraform + +# install kubectl +RUN curl -O https://s3.us-west-2.amazonaws.com/amazon-eks/1.28.3/2023-11-14/bin/linux/amd64/kubectl \ +&& chmod +x ./kubectl \ +&& cp ./kubectl /usr/local/bin/kubectl + +# install awscli +RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \ + && unzip awscliv2.zip \ + && sudo ./aws/install + +# install postgres +RUN echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" >/etc/apt/sources.list.d/pgdg.list \ + && wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \ + && apt-get update && apt-get -y install \ + postgresql-common \ + postgresql-client-common \ + postgresql-15 \ + postgresql-client-15 \ + libpq-dev + + # install docker compose + RUN sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose \ + && sudo chmod +x /usr/local/bin/docker-compose + + # install Python 3.11 + RUN sudo add-apt-repository ppa:deadsnakes/ppa \ + && sudo apt-get update \ + && sudo apt-get install -y python3.11 \ No newline at end of file diff --git a/.devcontainer/base_image/build_and_push_to_dockerhub.sh b/.devcontainer/base_image/build_and_push_to_dockerhub.sh new file mode 100644 index 0000000..d38e089 --- /dev/null +++ b/.devcontainer/base_image/build_and_push_to_dockerhub.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +docker build -t levg/ops-eng-container:latest . + +docker login + +docker tag levg/ops-eng-container:latest ministryofjustice/operations-engineering-devcontainer + +docker push ministryofjustice/operations-engineering-devcontainer \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..1931a2d --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,20 @@ +//devcontainer.json +{ + "name": "ops-eng-devcontainer", + + "containerEnv": {}, + + "image": "ministryofjustice/operations-engineering-devcontainer:latest", + + "features": { "ghcr.io/devcontainers/features/docker-in-docker:2": {} }, + + "runArgs": ["--name=ops-eng-devcontainer"], + + "customizations": { + "vscode": { + "extensions": ["alefragnani.project-manager", "amazonwebservices.aws-toolkit-vscode"] + } + }, + + "forwardPorts": [4567] +} diff --git a/README.md b/README.md index ee19bfd..a8359d0 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,22 @@ [![repo standards badge](https://img.shields.io/endpoint?labelColor=231f20&color=005ea5&style=for-the-badge&label=MoJ%20Compliant&url=https%3A%2F%2Foperations-engineering-reports.cloud-platform.service.justice.gov.uk%2Fapi%2Fv1%2Fcompliant_public_repositories%2Fendpoint%2Ftemplate-repository&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAABmJLR0QA/wD/AP+gvaeTAAAHJElEQVRYhe2YeYyW1RWHnzuMCzCIglBQlhSV2gICKlHiUhVBEAsxGqmVxCUUIV1i61YxadEoal1SWttUaKJNWrQUsRRc6tLGNlCXWGyoUkCJ4uCCSCOiwlTm6R/nfPjyMeDY8lfjSSZz3/fee87vnnPu75z3g8/kM2mfqMPVH6mf35t6G/ZgcJ/836Gdug4FjgO67UFn70+FDmjcw9xZaiegWX29lLLmE3QV4Glg8x7WbFfHlFIebS/ANj2oDgX+CXwA9AMubmPNvuqX1SnqKGAT0BFoVE9UL1RH7nSCUjYAL6rntBdg2Q3AgcAo4HDgXeBAoC+wrZQyWS3AWcDSUsomtSswEtgXaAGWlVI2q32BI0spj9XpPww4EVic88vaC7iq5Hz1BvVf6v3qe+rb6ji1p3pWrmtQG9VD1Jn5br+Knmm70T9MfUh9JaPQZu7uLsR9gEsJb3QF9gOagO7AuUTom1LpCcAkoCcwQj0VmJregzaipA4GphNe7w/MBearB7QLYCmlGdiWSm4CfplTHwBDgPHAFmB+Ah8N9AE6EGkxHLhaHU2kRhXc+cByYCqROs05NQq4oR7Lnm5xE9AL+GYC2gZ0Jmjk8VLKO+pE4HvAyYRnOwOH5N7NhMd/WKf3beApYBWwAdgHuCLn+tatbRtgJv1awhtd838LEeq30/A7wN+AwcBt+bwpD9AdOAkYVkpZXtVdSnlc7QI8BlwOXFmZ3oXkdxfidwmPrQXeA+4GuuT08QSdALxC3OYNhBe/TtzON4EziZBXD36o+q082BxgQuqvyYL6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NI+m712Ir+cer4POiqfHeJSVe1Raemwnm7xD3mD1E/Z3wIjcsTdlZnqO8bFeNB9c30zgVG2euYa69QJ+9G90lG+99bfdIoo5PU4w362xHePxl1slMab6tV72KUxDvzlAMT8G0ZohXq39VX1bNzzxij9K1Qb9lhdGe931B/kR6/zCwY9YvuytCsMlj+gbr5SemhqkyuzE8xau4MP865JvWNuj0b1YuqDkgvH2GkURfakly01Cg7Cw0+qyXxkjojq9Lw+vT2AUY+DlF/otYq1Ixc35re2V7R8aTRg2KUv7+ou3x/14PsUBn3NG51S0XpG0Z9PcOPKWSS0SKNUo9Rv2Mmt/G5WpPF6pHGra7Jv410OVsdaz217AbkAPX3ubkm240belCuudT4Rp5p/DyC2lf9mfq1iq5eFe8/lu+K0YrVp0uret4nAkwlB6vzjI/1PxrlrTp/oNHbzTJI92T1qAT+BfW49MhMg6JUp7ehY5a6Tl2jjmVvitF9fxo5Yq8CaAfAkzLMnySt6uz/1k6bPx59CpCNxGfoSKA30IPoH7cQXdArwCOllFX/i53P5P9a/gNkKpsCMFRuFAAAAABJRU5ErkJggg==)](https://operations-engineering-reports.cloud-platform.service.justice.gov.uk/public-report/template-repository) -Testing out using a devcontainer to accelerate local dev setup \ No newline at end of file +Testing out using a devcontainer to accelerate local dev setup. + +## How to run the container + +- Clone this repository. +- Run `sh .devcontainer/container_dependencies.sh` in the root of this repository to install the pre-requisites to build and run the devcontainer. +- The IDE should automatically open and prompt you to reopen the repository in a container, click 'Reopen in container', this + may take some time the first time as the container will need to be built. +- You are now developing in the devcontainer. + +## How to build the container + +- Modify .devcontainer/base_image/Dockerfile +- Run `sh .devcontainer/base_image/build_and_push_to_dockerhub.sh` +- That will update the base Docker image located at https://hub.docker.com/repository/docker/ministryofjustice/operations-engineering-devcontainer/general + +## Future developments + +- Secret integration e.g. using 1Password as here https://technical-documentation.data-platform.service.justice.gov.uk/documentation/platform/infrastructure/developing.html#prerequisites \ No newline at end of file From 7b5ff4ae6330dde886057cc028a99798d3c82598 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 10 Jan 2024 13:54:21 +0000 Subject: [PATCH 2/2] Commit changes made by code formatters --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a8359d0..1a766b6 100644 --- a/README.md +++ b/README.md @@ -12,12 +12,12 @@ Testing out using a devcontainer to accelerate local dev setup. may take some time the first time as the container will need to be built. - You are now developing in the devcontainer. -## How to build the container +## How to build the container - Modify .devcontainer/base_image/Dockerfile - Run `sh .devcontainer/base_image/build_and_push_to_dockerhub.sh` -- That will update the base Docker image located at https://hub.docker.com/repository/docker/ministryofjustice/operations-engineering-devcontainer/general +- That will update the base Docker image located at https://hub.docker.com/repository/docker/ministryofjustice/operations-engineering-devcontainer/general -## Future developments +## Future developments -- Secret integration e.g. using 1Password as here https://technical-documentation.data-platform.service.justice.gov.uk/documentation/platform/infrastructure/developing.html#prerequisites \ No newline at end of file +- Secret integration e.g. using 1Password as here https://technical-documentation.data-platform.service.justice.gov.uk/documentation/platform/infrastructure/developing.html#prerequisites