-
Notifications
You must be signed in to change notification settings - Fork 637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DevContainer! #11443
base: release-v0.16.x
Are you sure you want to change the base?
DevContainer! #11443
Changes from all commits
ec292fa
43bc07d
7164034
d84a61e
138f5d3
47a5071
22b1c09
4fe00d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. | ||
{ | ||
"name": "Kolibri Dev Container", | ||
"build": { | ||
"dockerfile": "../docker/base.dockerfile", | ||
"context": ".." | ||
}, | ||
"features": { | ||
"ghcr.io/devcontainers/features/common-utils:2": { | ||
"username": "devuser", | ||
"upgradePackages": true, | ||
"installZsh": false, | ||
"configureZshAsDefaultShell": false, | ||
"installOhMyZsh": false, | ||
"installOhMyZshConfig": false, | ||
"nonFreePackages": false | ||
} | ||
}, | ||
"workspaceMount": "source=${localWorkspaceFolder},target=/kolibri,type=bind", | ||
"workspaceFolder": "/kolibri", | ||
"forwardPorts": [ | ||
3000 | ||
], | ||
"portsAttributes": { | ||
"3000": { | ||
"label": "Webpack port", | ||
"onAutoForward": "silent" | ||
} | ||
}, | ||
"containerEnv": { | ||
"KOLIBRI_RUN_MODE": "docker_dev", | ||
"KOLIBRI_HOME": "/kolibri/.devcontainer/persist_dir/.kolibri" | ||
}, | ||
"remoteEnv": { | ||
"GIT_EDITOR": "nano" | ||
}, | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"ms-python.python", | ||
"ms-python.vscode-pylance", | ||
"octref.vetur", | ||
"editorconfig.editorconfig" | ||
] | ||
} | ||
}, | ||
"onCreateCommand": "yarn install --non-interactive --frozen-lockfile && pip install -e . && pre-commit install", | ||
"containerUser": "devuser", | ||
"remoteUser": "devuser" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This directory is used by the devcontainer to persist kolibri related directories. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,30 @@ | ||
FROM ubuntu:jammy | ||
|
||
ENV NODE_VERSION=16.20.0 | ||
|
||
# install required packages | ||
RUN apt-get update && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get install -y \ | ||
curl \ | ||
software-properties-common \ | ||
gettext \ | ||
git \ | ||
git-lfs \ | ||
psmisc \ | ||
python3 \ | ||
python3-pip \ | ||
python3-sphinx | ||
|
||
# add yarn ppa | ||
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - | ||
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list | ||
|
||
# install nodejs and yarn | ||
RUN apt-get update && \ | ||
ARCH=$(dpkg --print-architecture) && \ | ||
curl -sSO https://deb.nodesource.com/node_16.x/pool/main/n/nodejs/nodejs_$NODE_VERSION-1nodesource1_$ARCH.deb && \ | ||
dpkg -i ./nodejs_$NODE_VERSION-1nodesource1_$ARCH.deb && \ | ||
rm nodejs_$NODE_VERSION-1nodesource1_$ARCH.deb && \ | ||
apt-get install yarn | ||
|
||
RUN git lfs install | ||
|
||
# Check if symbolic links exist before creating them | ||
RUN if [ ! -f /usr/bin/python ]; then ln -s /usr/bin/python3 /usr/bin/python; fi \ | ||
&& if [ ! -f /usr/bin/pip ]; then ln -s /usr/bin/pip3 /usr/bin/pip; fi | ||
|
||
# copy Kolibri source code into image | ||
COPY . /kolibri | ||
|
||
# do the time-consuming base install commands | ||
RUN cd /kolibri \ | ||
&& pip3 install -r requirements/dev.txt \ | ||
&& pip3 install -r requirements/test.txt \ | ||
&& yarn install --network-timeout 100000 | ||
# This Dockerfile serves as a base image for Kolibri installations. It installs python, required OS packages, node, npm, yarn and python dependencies. | ||
|
||
# Declare python version argument. | ||
ARG PYTHON_VARIANT="3.9-slim" | ||
FROM python:${PYTHON_VARIANT} | ||
|
||
# Declare node major version argument. | ||
ARG NODE_MAJOR_VERSION="16" | ||
|
||
# Install only the absolutely-required packages to run Kolibri -- Git, Git-LFS, ip, ps and Node (plus npm). | ||
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y ca-certificates curl gnupg git git-lfs procps iproute2 \ | ||
&& mkdir -p /etc/apt/keyrings \ | ||
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \ | ||
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR_VERSION.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \ | ||
&& apt-get update && apt-get install -t nodistro -y nodejs | ||
|
||
# Install yarn. | ||
RUN npm install --global yarn | ||
|
||
# Change working directory for the commands that follow. | ||
WORKDIR /kolibri | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Presumably, one could have built an image of Kolibri, containing its source, with this file before this change. After this change, which removes The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Initially, my thought process was on those lines so I kept the devcontainer dockerfile completely isolated from deployable dockerfiles. But then eventually it turned out that keeping maintainability in mind utilising the base dockerfile would be better so went that route. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cc @rtibbles There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
These changes are backwards incompatible though, so you haven't kept any maintainability. The two images, a dev container image and a deployable image, have some commonalities such as installing python requirements, but overall have different use cases and responsibilities. For instance, a deployable Kolibri image doesn't need node.js (an existing dilemna) because node.js is only needed for building static JS/CSS resources. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, so having a separate dockerfile for devcontainer is better, isn't it? 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We discussed this a while back, and I asked that you think about this holistically considering we have the desire to make running Kolibri in a docker container more well documented and to potentially have a well-defined shippable image. As I said, the two use cases have commonalities in how define and build these docker images but they have different responsibilities. With There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I totally agree with you on this that the current approach of this PR has put everything in just the I think we need to decide on how our shippable docker image for Kolibri will look like so that we can decide whether we should build our devcontainer image on top of that or not. I think I should talk to David to sort this out as soon as we can...? |
||
|
||
# Copy python dependency files and install them. | ||
COPY requirements/ ./requirements | ||
COPY requirements.txt ./ | ||
RUN pip install --upgrade --root-user-action=ignore --default-timeout=150 pip \ | ||
&& pip install -r requirements.txt --upgrade --root-user-action=ignore --default-timeout=150 \ | ||
&& pip install -r requirements/dev.txt --upgrade --root-user-action=ignore --default-timeout=150 \ | ||
&& pip install -r requirements/test.txt --upgrade --root-user-action=ignore --default-timeout=150 \ | ||
&& pip install -r requirements/docs.txt --upgrade --root-user-action=ignore --default-timeout=150 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There isn't much benefit to setting up nodesource as a apt-repo inside the image. Also, there are better ways to handle this in a docker file, to better take advantage of caching.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nodesource suggested setting up apt-repo so that
apt update
andapt install
can figure out nodesource repo.https://github.com/nodesource/distributions?tab=readme-ov-file#installation-instructions
Regarding caching, I tried to keep the commands in one RUN command to make best use of caching. If there's more we can do to further improve on that then please let me know and I will do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, they'd suggest an apt-repo, but this is a container! It will likely only ever be installed once so it'll never use it for checking for updates!
For example, if the node.js version changes, this installs
ca-certificates curl gnupg git git-lfs procps iproute2
all over again. So no this isn't making the best use of caching.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So without apt-repo, how should we install node?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your changes here modified how we were doing it before, which was not to use the apt-repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah right, I will fix that with our refactor of base & dev dockerfiles.