Skip to content
This repository has been archived by the owner on Apr 1, 2022. It is now read-only.

Commit

Permalink
(#142) v0.5.0:
Browse files Browse the repository at this point in the history
* (#136) Perform image reduction;
* (#137) Use subshells when calling scripts in the Publish workflow;
* (#138) Fix the link to the `Theme adjustments? Why?` header;
* (#139) Add a config for WSL; set a value for `DISPLAY`;
* (#140) Use `GHCR_PAT` instead of `GH_TOKEN`;
* (#141) Fix the Publish workflow.
  • Loading branch information
Pavel Sobolev authored Apr 23, 2021
2 parents 716f7f2 + 4e8a167 commit 6dd9c6c
Show file tree
Hide file tree
Showing 27 changed files with 163 additions and 415 deletions.
28 changes: 23 additions & 5 deletions .github/scripts/publish.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,33 @@
# A script to build and push the image

# Build the image
podman build --squash-all -t $IMAGENAME .
podman --storage-opt=overlay.mount_program=/usr/bin/fuse-overlayfs build --squash-all -t ${IMAGENAME} .

# Login to the GHCR
echo $GHCR_PAT | podman login ghcr.io -u $USERNAME --password-stdin
echo ${GHCR_PAT} | podman login ghcr.io -u ${USERNAME} --password-stdin

# Push the latest version
podman push $IMAGENAME ghcr.io/$OWNER/$IMAGENAME:latest
podman push ${IMAGENAME} ghcr.io/${OWNER}/${IMAGENAME}:latest

# Push the release version
if [ "$PUBLISH_RELEASE_VERSION" = true ]; then
podman push $IMAGENAME ghcr.io/$OWNER/$IMAGENAME:$RELEASE_VERSION
if [ "${PUBLISH_RELEASE_VERSION}" = true ]; then

# Push the release version of the image
podman push ${IMAGENAME} ghcr.io/${OWNER}/${IMAGENAME}:${RELEASE_VERSION}

# Run a container
podman run --name container -td dev
podman stop container

# Export the container
FILE_TAR="dev-${RELEASE_VERSION}.tar"
FILE_ZIP="dev-${RELEASE_VERSION}.zip"
podman export container > ${FILE_TAR}
zip ${FILE_ZIP} ${FILE_TAR}

# Upload the archive as an asset to the latest release
AUTH="Authorization: token ${GHCR_PAT}"
RELEASE_ID=$(curl -sH "${AUTH}" "https://api.github.com/repos/${REPOSITORY}/releases/latest" | grep -m 1 "\"id\":" | sed -E 's/.*"id": (.*),/\1/')
UPLOAD_URL="https://uploads.github.com/repos/${REPOSITORY}/releases/${RELEASE_ID}/assets?name=${FILE_ZIP}"
curl -H "${AUTH}" -H "Content-Type: application/zip" --data-binary @"${FILE_ZIP}" ${UPLOAD_URL}
fi
18 changes: 9 additions & 9 deletions .github/scripts/version.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,37 @@
# release version should be pushed

# Get last published version
LAST_VERSION=$(curl --silent "https://api.github.com/repos/$REPOSITORY/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
LAST_VERSION=$(curl --silent "https://api.github.com/repos/${REPOSITORY}/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')

# Check if there is some tag
if [ ! -z "$LAST_VERSION" ]; then
if [ ! -z "${LAST_VERSION}" ]; then

# Get current tag
CURRENT_TAG=$(echo ${GITHUB_REF#refs/*/})

# Print info
echo -e "\n\e[1;36mLast version: $LAST_VERSION\e[0m"
echo -e "\e[1;36mCurrent tag: $CURRENT_TAG\e[0m\n"
echo -e "\n\e[1;36mLast version: ${LAST_VERSION}\e[0m"
echo -e "\e[1;36mCurrent tag: ${CURRENT_TAG}\e[0m\n"

# Check if the tag is a semantic version
if echo "$CURRENT_TAG" | grep -E "^v[0-9]+\.[0-9]+\.[0-9]+$"; then
if echo "${CURRENT_TAG}" | grep -E "^v[0-9]+\.[0-9]+\.[0-9]+$"; then

# Print information
echo -e "\e[1;36mCurrent tag is a semantic version. Tagged image will be published.\e[0m\n"

# Set environment variable
echo "RELEASE_VERSION=$(echo $CURRENT_TAG | sed 's/v//')" >> $GITHUB_ENV
echo "RELEASE_VERSION=$(echo ${CURRENT_TAG} | sed 's/v//')" >> ${GITHUB_ENV}

# Publish tagged image
echo "PUBLISH_RELEASE_VERSION=true" >> $GITHUB_ENV
echo "PUBLISH_RELEASE_VERSION=true" >> ${GITHUB_ENV}

else

# Print information
echo -e "\e[1;36mCurrent tag is not a semantic version. Tagged image will not be published.\e[0m\n"

# Don't publish tagged image
echo "PUBLISH_RELEASE_VERSION=false" >> $GITHUB_ENV
echo "PUBLISH_RELEASE_VERSION=false" >> ${GITHUB_ENV}

fi

Expand All @@ -44,6 +44,6 @@ else
echo -e "\n\e[1;36mNo release has been found, tagged version will not be published.\e[0m\n"

# Don't publish tagged image
echo "PUBLISH_RELEASE_VERSION=false" >> $GITHUB_ENV
echo "PUBLISH_RELEASE_VERSION=false" >> ${GITHUB_ENV}

fi
15 changes: 14 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,17 @@ jobs:
- name: Checkout the repository
uses: actions/checkout@master
- name: Build the image
run: podman build --squash-all -t dev .
run: podman --storage-opt=overlay.mount_program=/usr/bin/fuse-overlayfs build --squash-all -t dev .
- name: Run a container
run: |
podman run --name container -td dev
podman exec -it container echo "Hello, world!"
podman stop container
- name: Export the container
run: |
podman export container > dev-`echo ${{ github.event.pull_request.head.sha }} | cut -c1-7`.tar
- name: Upload the archive as an artifact
uses: actions/upload-artifact@v2
with:
name: dev-container
path: dev*.tar
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ jobs:
uses: actions/checkout@master
- name: Determine whether to upload a release version
run: bash .github/scripts/version.bash
- name: Publish to GHCR
- name: Publish the image and add a container archive to assets
run: bash .github/scripts/publish.bash
65 changes: 4 additions & 61 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
# Base image
FROM docker.io/library/ubuntu:20.10
FROM docker.io/bitnami/minideb:buster

# Meta information
LABEL maintainer="Pavel Sobolev (https://github.com/Paveloom)"
LABEL version="0.4.1"
LABEL version="0.5.0"
LABEL description="This is an image containing paveloom's personal development environment."
LABEL github-repository="https://github.com/paveloom-d/dev"
LABEL image-repository="https://hub.docker.com/r/paveloom/dev"

# Set the default shell for `RUN` commands
SHELL ["/bin/bash", "-c"]
LABEL image-repository="https://github.com/orgs/paveloom-d/packages/container/package/dev"

# Copy build scripts to the root
COPY build-scripts /build-scripts

# Allow their execution
RUN chmod -R +x /build-scripts

# Temporarily disable prompts during the build
ARG DEBIAN_FRONTEND=noninteractive

# Set a time zone for `tzdata`
ENV TZ=Europe/Moscow

# Install essential packages
RUN /build-scripts/root/install-essential-packages.bash

Expand All @@ -41,30 +32,6 @@ ENV HOME /home/$USER
# Set up a new user
RUN /build-scripts/root/set-up-a-new-user.bash

# Install X2Go Server and XFCE
RUN /build-scripts/root/install-x2go-and-xfce.bash

# Install a browser
RUN /build-scripts/root/install-browser.bash

# Install Python
RUN /build-scripts/root/install-python.bash

# Temporarily disable `apt-key` warnings
ARG APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1

# Install Podman and Buildah
RUN /build-scripts/root/install-podman-and-buildah.bash

# Install Node.js and npm
RUN /build-scripts/root/install-nodejs-and-npm.bash

# Install Rclone
RUN /build-scripts/root/install-rclone.bash

# Install TexLive
RUN /build-scripts/root/install-texlive.bash

# Switch to the home directory of the user
WORKDIR $HOME

Expand All @@ -78,34 +45,10 @@ RUN chown -R $USER:$USER Scripts && chmod -R +x Scripts
USER $USER

# Point to the hosts file for SSH
RUN /build-scripts/user/point-to-the-hosts-file.bash

# Activate the configuration for Rclone
RUN /build-scripts/user/touch-rclone-config.bash
RUN /build-scripts/user/add-configs.bash

# Install OhMyZsh
RUN /build-scripts/user/install-ohmyzsh.bash

# Add `~/.local/bin` to the `PATH`
ENV PATH=$PATH:/home/$USER/.local/bin

# Install Python packages
RUN /build-scripts/user/install-python-packages.bash

# Install Jupyter
RUN /build-scripts/user/install-jupyter.bash

# Add `~/.cargo/bin` to the `PATH`
ENV PATH=$PATH:/home/$USER/.cargo/bin

# Install Rust
RUN /build-scripts/user/install-rust.bash

# Add `~/Other/julia/bin` to the `PATH`
ENV PATH=$PATH:/home/$USER/Other/julia/bin

# Install Julia
RUN /build-scripts/user/install-julia.bash

# Remove build scripts
RUN sudo rm -rf /build-scripts
99 changes: 18 additions & 81 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,34 @@ remote development, but can also be used both locally and in the cloud.

### What's inside?

Well, what's not there? The list is large and varied, so see all the details under the
spoiler:
See all details under the spoiler:

<details>
<summary>Content of the image</summary>
<ul>
<li>Base image: <a href="https://hub.docker.com/_/ubuntu">Ubuntu</a> (20.10)</li>
<li>Base image: <a href="https://github.com/bitnami/minideb">minideb</a> (<em>buster</em>)</li>
<li>Essential packages:</li>
<ul>
<li><code>apt-utils</code></li>
<li><code>apt-transport-https</code></li>
<li><code>build-essential</code></li>
<li><code>dialog</code></li>
<li><code>dumb-init</code></li>
<li><code>htop</code></li>
<li><code>ca-certificates</code></li>
<li><code>git</code></li>
<li><code>make</code></li>
<li><code>screen</code></li>
<li><code>ncdu</code></li>
<li><code>zip</code></li>
<li><code>unzip</code></li>
<li><code>nano</code></li>
<li><code>less</code></li>
<li><code>wget</code></li>
<li><code>curl</code></li>
<li><code>gpg</code></li>
<li><code>gnupg-agent</code></li>
<li><a href="https://github.com/sudo-project/sudo"><code>sudo</code></a> (1.9.1)</li>
<li><code>sudo</code></li>
<li><code>ssh</code></li>
<li><code>keychain</code></li>
<li><code>locales</code></li>
<li><code>language-pack-en-base</code></li>
<li><code>software-properties-common</code></li>
</ul>
<li>Non-root user set-up</li>
<li><a href="#what-is-this-keychain-thing">Keychain to manage your SSH keys</a></li>
<li>X2Go Server and XFCE Desktop Environment</li>
<li>Midori Web Browser</li>
<li><a href="#auxiliary-user-scripts-huh-whats-that">Auxiliary user scripts</a></li>
<li>Zsh as the default shell:</li>
<ul>
Expand All @@ -66,58 +57,16 @@ spoiler:
</a>
</li>
</ul>
<li><a href="#theme-adjustments-why-is-that">Theme adjustments</a></li>
<li><a href="#theme-adjustments-why">Theme adjustments</a></li>
</ul>
</ul>
<li>Podman and Buildah</li>
<li>Python (3.8):</li>
<ul>
<li><code>python3-dev</code></li>
<li><code>python3-pip</code></li>
<li>Packages:</li>
<ul>
<li><code>wheel</code></li>
<li><code>numpy</code></li>
<li><code>matplotlib</code></li>
</ul>
</ul>
<li>Jupyter:</li>
<ul>
<li><code>jupyter</code></li>
<li><code>jupyterlab</code></li>
<li>
<a href="#i-see-jupyter-installed-there-how-do-i-use-it">
Aliases to run a notebook server
</a>
</li>
</ul>
<li>Rust</li>
<li>Julia (1.5.3):</li>
<ul>
<li><a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a></li>
<li><a href="https://github.com/fredrikekre/Literate.jl">Literate.jl</a></li>
<li><a href="https://github.com/timholy/Revise.jl">Revise.jl</a></li>
<li><a href="https://github.com/JuliaLang/IJulia.jl">IJulia.jl</a></li>
<li><a href="https://github.com/JuliaPy/PyPlot.jl">PyPlot.jl</a></li>
<li><a href="https://github.com/JuliaPlots/Plots.jl">Plots.jl</a></li>
</ul>
<li>Node.js and npm</li>
<li>Rclone</li>
<li>TexLive:</li>
<ul>
<li><code>dvipng</code></li>
<li><code>texlive-latex-extra</code></li>
<li><code>texlive-fonts-extra</code></li>
<li><code>texlive-lang-cyrillic</code></li>
<li><code>cm-super</code></li>
</ul>
</ul>
</details>

### How do I get it?

I recommend using [Podman](https://podman.io) for building the image and running a container,
although the same can be done using [Docker](https://www.docker.com).
I recommend using [Podman](https://podman.io) for pulling and building the image or running
a container, although the same can be done using [Docker](https://www.docker.com).

Since `v0.4.0`, the image can be pulled from
[GitHub Container Registry](https://github.com/orgs/paveloom-d/packages/container/package/dev):
Expand All @@ -136,6 +85,10 @@ from [GitHub Packages](https://github.com/paveloom-d/dev/packages/290377):
podman pull docker.io/paveloom/dev:tag
```

Since `v0.5.0` container archives are provided as part of the
[releases](https://github.com/paveloom-d/dev/releases). These can be used for importing a
container using Docker / Podman or for registering as a WSL distribution.

### Can I build the image myself?

Yes. To build the image, checkout the repository from a tagged commit on the `master` branch
Expand All @@ -157,26 +110,6 @@ Since Zsh is the default shell, you can enter the container using the following
podman exec -it container zsh
```

### I see Jupyter installed there. How do I use it?

To use Jupyter Notebook or Jupyter Lab you will need to do two things.

First, publish the `8888` port (or any other, but this one is standard) when running a
container:

```bash
podman run -p 8888:8888 --name container -t -d dev
```

Next, while inside the container, run the notebook server listening on IP `0.0.0.0`:

```bash
jupyter notebook --ip 0.0.0.0 --no-browser
```

There are handy aliases for the last step: `jnote` for Jupyter Notebook and `jlab` for
Jupyter Lab.

### I don't see any password requests. Is that normal?

Yes. The system will not ask the user to enter a password (this makes it
Expand Down Expand Up @@ -219,8 +152,12 @@ in the `~/.zshrc`, just uncomment them and specify your keys.
### Auxiliary user scripts, huh? What's that?

The image provides auxiliary scripts that can help the user create SSH and GPG keys and
connect them to an account on GitHub. Also, these scripts adjust Git config and add several
Git aliases. They are located in `~/Scripts`.
connect them to an account on GitHub. These scripts adjust Git config and add several
Git aliases.

Also, scripts to install the latest stable versions of Julia and Rust are included.

They are located in `~/Scripts`.

### Theme adjustments? Why?

Expand Down
12 changes: 0 additions & 12 deletions build-scripts/root/install-browser.bash

This file was deleted.

Loading

0 comments on commit 6dd9c6c

Please sign in to comment.