mirror of
https://github.com/livebook-dev/livebook.git
synced 2024-09-20 10:05:57 +08:00
GitHub Codespaces: Add devcontainer.json
files to Livebook (#1138)
This commit is contained in:
parent
f39699b65e
commit
caeb23fe48
46
.devcontainer/Dockerfile
Normal file
46
.devcontainer/Dockerfile
Normal file
|
@ -0,0 +1,46 @@
|
|||
# This image version needs to match what is in the root Dockerfile.
|
||||
FROM hexpm/elixir:1.13.2-erlang-24.1.7-debian-bullseye-20210902-slim
|
||||
|
||||
ENV HOME=/home/livebook
|
||||
ENV PATH ${PATH}:${HOME}/.mix/escripts
|
||||
|
||||
# GitHub Codespaces put you in a `/workspaces` folder no matter what.
|
||||
ENV WORKSPACE_FOLDER=/workspaces/livebook
|
||||
|
||||
WORKDIR ${WORKSPACE_FOLDER}
|
||||
|
||||
# Install the dependencies from the build image (which is discarded in the normal production images)
|
||||
RUN apt-get update && apt-get upgrade -y && \
|
||||
apt-get install --no-install-recommends -y \
|
||||
# Bash (for easier shell use)
|
||||
bash \
|
||||
# Runtime dependencies
|
||||
build-essential ca-certificates libncurses5-dev inotify-tools \
|
||||
# In case someone uses `Mix.install/2` and point to a git repo
|
||||
git \
|
||||
# Additional standard tools
|
||||
curl wget \
|
||||
# In case someone uses Torchx for Nx
|
||||
cmake && \
|
||||
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false && \
|
||||
apt-get clean -y && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install hex and rebar
|
||||
RUN mix local.hex --force && mix local.rebar --force
|
||||
|
||||
# Node/nvm setup
|
||||
ARG NODE_SCRIPT_SOURCE="https://raw.githubusercontent.com/microsoft/vscode-dev-containers/main/script-library/node-debian.sh"
|
||||
ARG NODE_SCRIPT_SHA="dev-mode"
|
||||
ARG NODE_VERSION="14"
|
||||
ENV NVM_DIR=/usr/local/share/nvm
|
||||
ENV NVM_SYMLINK_CURRENT=true
|
||||
ENV PATH=${NVM_DIR}/current/bin:${PATH}
|
||||
|
||||
RUN curl -sSL ${NODE_SCRIPT_SOURCE} -o /tmp/node-setup.sh && \
|
||||
/bin/bash /tmp/node-setup.sh "${NVM_DIR}" "${NODE_VERSION}" "${USERNAME}"
|
||||
|
||||
# On Codespaces the code is automatically copied and we run the setup as a hook,
|
||||
# we still do this for the image, so the container can be tested on its own
|
||||
COPY . .
|
||||
RUN mix do dev.setup, deps.compile, compile
|
27
.devcontainer/devcontainer.json
Normal file
27
.devcontainer/devcontainer.json
Normal file
|
@ -0,0 +1,27 @@
|
|||
// For format details, see https://aka.ms/devcontainer.json.
|
||||
// Also see https://github.com/microsoft/vscode-dev-containers/tree/v0.231.6/containers/elixir-phoenix-postgres
|
||||
{
|
||||
"name": "Livebook development environment",
|
||||
"dockerComposeFile": "docker-compose.yml",
|
||||
"service": "livebook_dev",
|
||||
|
||||
// Despite being required to set workspaceFolder, it doesn't actually do anything and you end up in /workspaces/livebook no matter what.
|
||||
"workspaceFolder": "/workspaces/livebook",
|
||||
|
||||
// Codespaces will mount the source code and overwrite the build artifacts that the Dockerfile creates, so we rebuild with a lifecycle script.
|
||||
"updateContentCommand": "mix do dev.setup, deps.compile, compile",
|
||||
|
||||
"extensions": ["jakebecker.elixir-ls"],
|
||||
"forwardPorts": [4000, 4001, 8080, 8081],
|
||||
"otherPortsAttributes": {
|
||||
"onAutoForward": "ignore"
|
||||
},
|
||||
"settings": {
|
||||
// Needed because of: https://github.com/microsoft/vscode/issues/102057#issuecomment-657728467
|
||||
"debug.javascript.autoAttachFilter": "onlyWithFlag",
|
||||
"debug.javascript.autoAttachSmartPattern": [
|
||||
"!**/node_modules/**",
|
||||
"**/$KNOWN_TOOLS$/**"
|
||||
]
|
||||
},
|
||||
}
|
19
.devcontainer/docker-compose.yml
Normal file
19
.devcontainer/docker-compose.yml
Normal file
|
@ -0,0 +1,19 @@
|
|||
version: "3.8"
|
||||
|
||||
services:
|
||||
livebook_dev:
|
||||
container_name: livebook_dev
|
||||
image: livebook_dev:latest
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: ./.devcontainer/Dockerfile
|
||||
environment:
|
||||
- LIVEBOOK_HOME=/data
|
||||
- LIVEBOOK_DATA_PATH=/data
|
||||
# Overrides default command so things don't shut down after the process ends.
|
||||
command: sleep infinity
|
||||
ports:
|
||||
- "8080:8080"
|
||||
- "8081:8081"
|
||||
- "4000:4000"
|
||||
- "4001:4001"
|
|
@ -126,6 +126,15 @@ If you want to run Livebook on embedded devices, such as Raspberry Pi, BeagleBon
|
|||
check out [our Livebook firmware](https://github.com/livebook-dev/nerves_livebook) built
|
||||
with [Nerves](https://www.nerves-project.org/).
|
||||
|
||||
### GitHub Codespaces (development)
|
||||
|
||||
Livebook also has a `devcontainer.json` file for launching containers
|
||||
on [GitHub Codespaces](https://github.com/features/codespaces) for development
|
||||
purposes. Once booted, you can invoke `mix phx.server` in the terminal to start
|
||||
your own Livebook session.
|
||||
|
||||
Check [the official GitHub Codespaces documentation](https://docs.github.com/en/codespaces/developing-in-codespaces/creating-a-codespace#creating-a-codespace) to learn more.
|
||||
|
||||
## Security considerations
|
||||
|
||||
Livebook is built to document and execute code. Anyone with access to a Livebook instance
|
||||
|
|
Loading…
Reference in a new issue