Skip to content

Commit

Permalink
Merge pull request #2 from ministryofjustice/devcontainer-cleanup
Browse files Browse the repository at this point in the history
Build base image and push to Dockerhub
  • Loading branch information
levgorbunov1 authored Jan 10, 2024
2 parents 10633d5 + 7b5ff4a commit ac669d0
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 4 deletions.
67 changes: 67 additions & 0 deletions .devcontainer/base_image/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions .devcontainer/base_image/build_and_push_to_dockerhub.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

"containerEnv": {},

"dockerFile": "Dockerfile",
"image": "ministryofjustice/operations-engineering-devcontainer:latest",

"features": { "ghcr.io/devcontainers/features/docker-in-docker:2": {} },

Expand Down
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@

Testing out using a devcontainer to accelerate local dev setup.

## How to
## 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.

## 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
## 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

0 comments on commit ac669d0

Please sign in to comment.