From 405f791379d8beed751e8d03abbf0f39c9951619 Mon Sep 17 00:00:00 2001 From: Alexander Kolotov Date: Mon, 30 Sep 2024 17:05:49 -0600 Subject: [PATCH] Initial commit --- .github/workflows/main.yml | 42 +++++++++++++++++++++++++++++++ Dockerfile | 51 ++++++++++++++++++++++++++++++++++++++ README.md | 4 +++ 3 files changed, 97 insertions(+) create mode 100644 .github/workflows/main.yml create mode 100644 Dockerfile create mode 100644 README.md diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..479b53a --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,42 @@ +name: Build Elixir devcontainer image + +on: + push: + +env: + DOCKER_REGISTRY: ghcr.io + DOCKER_USERNAME: ${{ github.actor }} + DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }} + IMAGE_NAME: ghcr.io/blockscout/devcontainer-elixir + +jobs: + build-elixir: + name: Docker image + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + images: ${{ env.IMAGE_NAME }} + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ${{ env.DOCKER_REGISTRY }} + username: ${{ env.DOCKER_USERNAME }} + password: ${{ env.DOCKER_PASSWORD }} + - name: Build and push + uses: docker/build-push-action@v3 + with: + push: true + platforms: linux/amd64,linux/arm64 + file: ./Dockerfile + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e5417f6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,51 @@ +ARG VARIANT="1.17.3-erlang-27.1-debian-bullseye-20240926" +ARG PHOENIX_VERSION="1.7.10" +ARG NODE_VERSION="18" +FROM hexpm/elixir:${VARIANT} + +# This Dockerfile adds a non-root user with sudo access. Update the “remoteUser” property in +# devcontainer.json to use it. More info: https://aka.ms/vscode-remote/containers/non-root-user. +ARG USERNAME=vscode +ARG USER_UID=1000 +ARG USER_GID=$USER_UID + +# Options for common package install script +ARG INSTALL_ZSH="true" +ARG UPGRADE_PACKAGES="true" +ARG COMMON_SCRIPT_SOURCE="https://raw.githubusercontent.com/microsoft/vscode-dev-containers/main/script-library/common-debian.sh" +ARG COMMON_SCRIPT_SHA="dev-mode" + +# [Optional] Setup nodejs +ARG NODE_SCRIPT_SOURCE="https://raw.githubusercontent.com/microsoft/vscode-dev-containers/main/script-library/node-debian.sh" +ARG NODE_SCRIPT_SHA="dev-mode" +ENV NVM_DIR=/usr/local/share/nvm +ENV NVM_SYMLINK_CURRENT=true +ENV PATH=${NVM_DIR}/current/bin:${PATH} + +# Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies. +RUN apt-get update \ + && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install --no-install-recommends curl ca-certificates 2>&1 \ + && curl -sSL ${COMMON_SCRIPT_SOURCE} -o /tmp/common-setup.sh \ + && ([ "${COMMON_SCRIPT_SHA}" = "dev-mode" ] || (echo "${COMMON_SCRIPT_SHA} */tmp/common-setup.sh" | sha256sum -c -)) \ + && /bin/bash /tmp/common-setup.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" \ + # + # [Optional] Install Node.js for use with web applications + && if [ "$NODE_VERSION" != "none" ]; then \ + curl -sSL ${NODE_SCRIPT_SOURCE} -o /tmp/node-setup.sh \ + && ([ "${NODE_SCRIPT_SHA}" = "dev-mode" ] || (echo "${NODE_SCRIPT_SHA} */tmp/node-setup.sh" | sha256sum -c -)) \ + && /bin/bash /tmp/node-setup.sh "${NVM_DIR}" "${NODE_VERSION}" "${USERNAME}" \ + && npm install -g cspell@latest; \ + fi \ + # + # Install dependencies + && apt-get install -y build-essential inotify-tools \ + # + # Clean up + && apt-get autoremove -y \ + && apt-get clean -y \ + && rm -rf /var/lib/apt/lists/* /tmp/common-setup.sh /tmp/node-setup.sh + +RUN su ${USERNAME} -c "mix local.hex --force \ + && mix local.rebar --force \ + && mix archive.install --force hex phx_new ${PHOENIX_VERSION}" diff --git a/README.md b/README.md new file mode 100644 index 0000000..dc35aac --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +Elixir based devcontainer image +---- + +This repo contains the docker file to build a docker image that can be used as a base for VSCode devcontainers.