Skip to content

Commit

Permalink
HAI-654 Create base Coder Ubuntu image (#2)
Browse files Browse the repository at this point in the history
* Add Dockerfile, workflow and scripts

* Unminimize
  • Loading branch information
jamesconstable authored Nov 25, 2022
1 parent 0109210 commit 399a424
Show file tree
Hide file tree
Showing 6 changed files with 163 additions and 1 deletion.
31 changes: 31 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build and publish

on:
pull_request:
branches:
- main
release:
types: [published]

jobs:
build:
name: Build and publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Build the image
run: make build

- name: Log in to Docker Hub
uses: docker/login-action@v2
if: github.event_name == 'release'
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Publish the image
if: github.event_name == 'release'
run: make publish
env:
TAG: ${{ github.ref_name }}
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

.DEFAULT_GOAL := help
IMAGE_NAME := harrisonai/coder-dev

build:
./scripts/build.sh $(IMAGE_NAME)

publish:
@test -n "${TAG}" || ( echo "TAG environment variable must be set" && return 1 )
./scripts/publish.sh $(IMAGE_NAME) ${TAG}

help:
@sed -ne '/@sed/!s/## //p' $(MAKEFILE_LIST)
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,26 @@
# cobalt-docker-coder-dev
Docker images for Coder development

Base Docker images for Coder development

## 💡 Motivation
Our goal is to provide a base Docker image for the [Coder](https://coder.com/) environment that allows developers to quickly get started with basic prerequisites for ML development.

## 🔧 What’s inside ?

Currently we provide a single image based on [Coder’s “Enterprise Base” Docker image](https://hub.docker.com/r/codercom/enterprise-base), with the following additional tools included:

* Python 3.8
* [AWS CLI](https://aws.amazon.com/cli/)
* [Kubernetes CL tool (`kubectl`)](https://kubernetes.io/docs/reference/kubectl/)
* other useful utilities (`ffmpeg`, `libsm6`, `libxext6`, `direnv`, `net-tools`, `iputils-ping`, `dnsutils`, `iproute2`, `tmux`, `bash-completion`, `zsh`)

## 🚀 Usage

To launch a CLI:

```bash
docker run -it --entrypoint /bin/bash harrisonai/coder-dev:base
```

## 📖 License
This project is licensed under [Apache License 2.0](https://github.com/harrison-ai/cobalt-docker-coder-dev/blob/main/LICENSE).
50 changes: 50 additions & 0 deletions base/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Pinned to 2022-11-12 version of "ubuntu" tag
FROM codercom/enterprise-base@sha256:f58cce5a5c00dca76e53a54aab3eea0fcac3be9875fd0b9bda1d8e16f6bf5c22

USER root

RUN sed -i 's#/archive.ubuntu.com#/au.archive.ubuntu.com#g' /etc/apt/sources.list \
&& apt-get update \
&& apt-get install --no-install-recommends -y \
apt-utils \
bash-completion \
ca-certificates \
curl \
dialog \
direnv \
dnsutils \
ffmpeg \
git \
iproute2 \
iputils-ping \
libsm6 \
libxext6 \
net-tools \
openssh-client \
python3.8 \
python3.8-venv \
tmux \
unzip \
zsh \
&& apt-get upgrade -y \
&& yes | unminimize \
&& rm -rf /var/lib/apt/lists/*

RUN pip install -Uq pip pip-tools
ENV PATH="${PATH}:/home/coder/.local/bin"

ARG AWS_VERSION=2.7.18
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-${AWS_VERSION}.zip" -o "/tmp/awscliv2.zip" && \
unzip -q /tmp/awscliv2.zip -d /tmp && \
/tmp/aws/install && \
rm -rf /tmp/aws /tmp/awscliv2.zip

ARG KUBE_VERSION=1.22.12
RUN curl -LO "https://dl.k8s.io/release/v${KUBE_VERSION}/bin/linux/amd64/kubectl" && \
chmod +x kubectl && \
mv kubectl /usr/local/bin

RUN ssh-keyscan github.com 2>/dev/null > /etc/ssh/ssh_known_hosts

USER coder
WORKDIR /home/coder
14 changes: 14 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

# Builds the docker images

set -e

if [ "$#" -ne 1 ]; then
>&2 echo "Usage: $(basename $0) <image-name>"
exit 1
fi

IMAGE_NAME="$1"

docker build -t "${IMAGE_NAME}:base" base
30 changes: 30 additions & 0 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

# Publishes images to Docker Hub

# We expect this repo to one day contain multiple useful Coder images, but currently it
# only has one option, 'base'. To keep tag names coherent, we're providing three ways to
# reference variants:
# * by release number and variant name (e.g. harrisonai/coder-dev:0.1.0-base),
# * by variant name alone (e.g. harrisonai/coder-dev:base, which will always use the
# most recent release), and
# * by default/latest, which will always be the most recent release of 'base'.

set -e

if [ "$#" -ne 2 ]; then
>&2 echo "Usage: $(basename $0) <image-name> <version-tag>"
exit 1
fi

IMAGE_NAME="$1"
VERSION="${2#v}"

echo "🏷️ Adding tags for image '${IMAGE_NAME}:base': ${VERSION}-base, latest"
docker tag "${IMAGE_NAME}:base" "${IMAGE_NAME}:${VERSION}-base"
docker tag "${IMAGE_NAME}:base" "${IMAGE_NAME}:latest"

echo "📤 Pushing '${IMAGE_NAME}:${TAG}-base', '${IMAGE_NAME}:base', and '${IMAGE_NAME}:latest'"
docker push "${IMAGE_NAME}:${TAG}-base"
docker push "${IMAGE_NAME}:base"
docker push "${IMAGE_NAME}:latest"

0 comments on commit 399a424

Please sign in to comment.