Skip to content

Instantly share code, notes, and snippets.

@matobaa
Created September 18, 2023 18:24
Show Gist options
  • Save matobaa/e820b9db14e5b87bf4711f0be3828d47 to your computer and use it in GitHub Desktop.
Save matobaa/e820b9db14e5b87bf4711f0be3828d47 to your computer and use it in GitHub Desktop.
mojo dockerfile for a vscode user who is not root
FROM ubuntu:latest
# see also: https://developer.modular.com/download#:~:text=Manual%20installation%20steps
# install prerequirements
RUN apt-get update && apt-get install -y --no-install-recommends \
apt-transport-https \
ca-certificates \
curl \
gnupg \
&& apt-get -y clean
# install modular
RUN apt-get install -y apt-transport-https && \
keyring_location=/usr/share/keyrings/modular-installer-archive-keyring.gpg && \
curl -1sLf 'https://dl.modular.com/bBNWiLZX5igwHXeu/installer/gpg.0E4925737A3895AD.key' | gpg --dearmor >> ${keyring_location} && \
curl -1sLf 'https://dl.modular.com/bBNWiLZX5igwHXeu/installer/config.deb.txt?distro=debian&codename=wheezy' > /etc/apt/sources.list.d/modular-installer.list && \
apt-get update && \
apt-get install -y modular && \
apt-get -y clean
# add user who is not admin
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
&& chmod 0440 /etc/sudoers.d/$USERNAME
WORKDIR /home/$USERNAME
USER $USER_UID
# install mojo
# docker build --build-args MODULAR_AUTH=your_modular_auth_token
ARG MODULAR_AUTH
RUN modular auth $MODULAR_AUTH
RUN modular install mojo
RUN echo 'export MODULAR_HOME=$HOME/.modular' >> /home/$USERNAME/.bashrc
RUN echo 'export PATH=$HOME/.modular/pkg/packages.modular.com_mojo/bin:$PATH' >> /home/$USERNAME/.bashrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment