From 01e416f0dd36e2e32ed0dfa0db38a6c44370d6ae Mon Sep 17 00:00:00 2001 From: Badlop Date: Mon, 5 Dec 2022 18:15:28 +0100 Subject: [PATCH] Add code-server and devcontainer images, useful for VSCode --- .github/workflows/code-server.yml | 42 +++++++++++++++++++ .github/workflows/devcontainer.yml | 42 +++++++++++++++++++ README.md | 20 ++++++--- code-server/Dockerfile | 26 ++++++++++++ devcontainer/Dockerfile | 65 ++++++++++++++++++++++++++++++ 5 files changed, 190 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/code-server.yml create mode 100644 .github/workflows/devcontainer.yml create mode 100644 code-server/Dockerfile create mode 100644 devcontainer/Dockerfile diff --git a/.github/workflows/code-server.yml b/.github/workflows/code-server.yml new file mode 100644 index 0000000..7cc6881 --- /dev/null +++ b/.github/workflows/code-server.yml @@ -0,0 +1,42 @@ +name: code-server + +on: + push: + paths: + - '.github/workflows/code-server.yml' + - 'code-server/**' + +jobs: + + code-server: + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + + - uses: actions/checkout@v3 + + - name: Build image + run: docker build + code-server + --tag code-server + + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Push image + run: | + IMAGE_ID=ghcr.io/${{ github.repository_owner }}/code-server + # Strip git ref prefix from version + VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') + # Use Docker `latest` tag convention + [ "$VERSION" == "master" ] && VERSION=latest + docker tag code-server $IMAGE_ID:$VERSION + docker push $IMAGE_ID:$VERSION diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml new file mode 100644 index 0000000..f4c76e0 --- /dev/null +++ b/.github/workflows/devcontainer.yml @@ -0,0 +1,42 @@ +name: devcontainer + +on: + push: + paths: + - '.github/workflows/devcontainer.yml' + - 'devcontainer/**' + +jobs: + + devcontainer: + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + + - uses: actions/checkout@v3 + + - name: Build image + run: docker build + devcontainer + --tag devcontainer + + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Push image + run: | + IMAGE_ID=ghcr.io/${{ github.repository_owner }}/devcontainer + # Strip git ref prefix from version + VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') + # Use Docker `latest` tag convention + [ "$VERSION" == "master" ] && VERSION=latest + docker tag devcontainer $IMAGE_ID:$VERSION + docker push $IMAGE_ID:$VERSION diff --git a/README.md b/README.md index 11f3676..343c4f1 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,20 @@ This repository contains a set of Docker images for ejabberd: - [mix](mix/) (in Docker Hub: [ejabberd/mix](https://hub.docker.com/r/ejabberd/mix/)): - allows you to build a development - environment for ejabberd, using all dependencies packaged from the Docker image. You do not - need anything else to build ejabberd from source and write your own ejabberd plugins. + + Build a development environment for ejabberd. See [mix README](mix/README.md) file for details. + - [ecs](ecs/) (in Docker Hub: [ejabberd/ecs](https://hub.docker.com/r/ejabberd/ecs/)): - is suitable for running ejabberd with Docker in a simple, single-node setup. -Please read the README file in each repository for documentation for each image. + Run ejabberd with Docker in a simple, single-node setup. + See [ecs README](ecs/README.md) file for details. + +- [code-server](code-server/) (in GitHub Container Registry: [processone/code-server](https://github.com/orgs/processone/packages/container/package/code-server)): + + Run Coder's code-server with a local ejabberd git clone. + See [VSCode section](https://docs.ejabberd.im/developer/vscode/) in ejabberds Docs. + +- [devcontainer](devcontainer/) (in GitHub Container Registry: [processone/devcontainer](https://github.com/orgs/processone/packages/container/package/devcontainer)): + + Use as a Dev Container for ejabberd in Visual Studio Code. + See [VSCode section](https://docs.ejabberd.im/developer/vscode/) in ejabberds Docs. diff --git a/code-server/Dockerfile b/code-server/Dockerfile new file mode 100644 index 0000000..72fceb6 --- /dev/null +++ b/code-server/Dockerfile @@ -0,0 +1,26 @@ +FROM debian:unstable-slim + +RUN apt-get update \ + && apt-get -y --no-install-recommends install \ + curl ca-certificates \ + autoconf automake git make gcc g++ \ + erlang erlang-dev elixir rebar3 \ + libexpat1-dev libgd-dev libpam0g-dev \ + libsqlite3-dev libwebp-dev libyaml-dev \ + libssl-dev + +RUN curl -fsSL https://code-server.dev/install.sh | sh + +RUN addgroup vscode --gid 1000 \ + && adduser --shell /bin/bash --ingroup vscode vscode -u 1000 + +USER vscode + +RUN /usr/bin/code-server --install-extension erlang-ls.erlang-ls + +RUN echo "export PATH=/workspaces/ejabberd/_build/relive:$PATH" >>/home/vscode/.bashrc +RUN echo "COOKIE" >/home/vscode/.erlang.cookie +RUN chmod 400 /home/vscode/.erlang.cookie + +WORKDIR /workspaces/ejabberd +ENTRYPOINT ["code-server", "--bind-addr", "0.0.0.0:5208", "--auth", "none", "/workspaces/ejabberd"] diff --git a/devcontainer/Dockerfile b/devcontainer/Dockerfile new file mode 100644 index 0000000..8b98dc0 --- /dev/null +++ b/devcontainer/Dockerfile @@ -0,0 +1,65 @@ +# [Choice] Alpine version: 3.16, 3.15, 3.14, 3.13 +ARG VARIANT=latest +FROM alpine:${VARIANT} + +RUN apk upgrade --update musl \ + && apk add \ + autoconf \ + automake \ + bash \ + build-base \ + curl \ + elixir \ + erlang-debugger \ + erlang-observer \ + erlang-odbc \ + erlang-reltool \ + expat-dev \ + file \ + gd-dev \ + git \ + jpeg-dev \ + libpng-dev \ + libwebp-dev \ + linux-pam-dev \ + openssl \ + openssl-dev \ + sqlite-dev \ + yaml-dev \ + zlib-dev + +# [Option] Install zsh +ARG INSTALL_ZSH="true" + +# Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies. +ARG USERNAME=vscode +ARG USER_UID=1000 +ARG USER_GID=$USER_UID +ARG COMMON_SCRIPT_SOURCE="https://raw.githubusercontent.com/devcontainers/images/main/src/base-alpine/.devcontainer/library-scripts/common-alpine.sh" +RUN apk update \ + && curl -sSL ${COMMON_SCRIPT_SOURCE} -o /tmp/common-alpine.sh \ + && ash /tmp/common-alpine.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" \ + && rm -rf /tmp/common-alpine.sh + +RUN mix local.hex --force \ + && mix local.rebar --force + +RUN apk add \ + expat \ + freetds \ + gd \ + jpeg \ + libgd \ + libpng \ + libstdc++ \ + libwebp \ + linux-pam \ + ncurses-libs \ + openssl \ + sqlite \ + sqlite-libs \ + unixodbc \ + yaml \ + zlib \ + && ln -fs /usr/lib/libtdsodbc.so.0 /usr/lib/libtdsodbc.so \ + && rm -rf /var/cache/apk/*