This commit is contained in:
Tine Jozelj 2021-03-07 11:52:02 +01:00
parent c786ea86a7
commit 1412addfb1
5 changed files with 10 additions and 127 deletions

View file

@ -1,77 +0,0 @@
name: workspace
on:
schedule:
- cron: '0 6 * * *'
pull_request:
branches: main
push:
branches: main
tags:
- v*
jobs:
workspace:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Prepare
id: prepare
run: |
DOCKER_IMAGE=ghcr.io/mentos1386/workspace
DOCKER_PLATFORMS=linux/amd64,linux/arm64
VERSION=edge
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
fi
if [ "${{ github.event_name }}" = "schedule" ]; then
VERSION=nightly
fi
TAGS="--tag ${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS --tag ${DOCKER_IMAGE}:latest"
fi
echo ::set-output name=docker_image::${DOCKER_IMAGE}
echo ::set-output name=version::${VERSION}
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \
--build-arg REPOSITORY=ghcr.io/mentos1386 \
--build-arg VERSION=${VERSION} \
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
--build-arg VCS_REF=${GITHUB_SHA::8} \
--cache-from "type=local,src=/tmp/.buildx-cache" \
--cache-to "type=local,dest=/tmp/.buildx-cache" \
${TAGS} --file ./Dockerfile .
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-workspace-${{ github.sha }}
restore-keys: |
${{ runner.os }}-workspace-
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Docker Buildx (build)
run: |
docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }}
- name: Login to Github Registry
if: success() && github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- name: Docker Buildx (push)
if: success() && github.event_name != 'pull_request'
run: |
docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}
- name: Inspect image
if: always() && github.event_name != 'pull_request'
run: |
docker buildx imagetools inspect ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}

View file

@ -1,5 +1,5 @@
# vim: set fenc=utf-8 ts=2 sw=2 sts=2 et ft=Dockerfile :
FROM alpine:3.12
FROM node:15-alpine
LABEL maintainer="Tine <mentos1386> Jozelj <tine@tjo.space>"
LABEL org.opencontainers.image.source https://github.com/mentos1386/workspace
@ -42,22 +42,9 @@ RUN echo "PubkeyAuthentication yes" >> /etc/ssh/sshd_config \
# install tools
COPY --from=ghcr.io/mentos1386/starship:0.47.0 /usr/local/bin/starship /usr/local/bin/starship
COPY --from=ghcr.io/mentos1386/kubectl:1.20.0 /usr/local/bin/kubectl /usr/local/bin/kubectl
COPY --from=ghcr.io/mentos1386/glow:1.3.0 /usr/local/bin/glow /usr/local/bin/glow
COPY --from=ghcr.io/mentos1386/mosh:master /usr/bin/mosh /usr/bin/mosh
COPY --from=ghcr.io/mentos1386/mosh:master /usr/bin/mosh-server /usr/bin/mosh-server
COPY --from=ghcr.io/mentos1386/mosh:master /usr/bin/mosh-client /usr/bin/mosh-client
# Golang
COPY --from=golang:1.15.6-alpine --chown=${SSH_USER} /usr/local/go /home/${SSH_USER}/.go
ENV PATH=/home/${SSH_USER}/.go/bin:$PATH
# Rust
COPY --from=ghcr.io/mentos1386/rust:1.48.0 --chown=${SSH_USER} /usr/local/cargo /home/${SSH_USER}/.cargo
COPY --from=ghcr.io/mentos1386/rust:1.48.0 --chown=${SSH_USER} /usr/local/rustup /home/${SSH_USER}/.rustup
ENV CARGO_HOME=/home/${SSH_USER}/.cargo
ENV RUSTUP_HOME=/home/${SSH_USER}/.rustup
ENV PATH=/home/${SSH_USER}/.cargo/bin:$PATH
# Node
COPY --from=node:15.5.0-alpine /usr/local/bin/node /usr/local/bin/node
# TODO: Add yarbn/npm/npx/yarnpkg??
# Create .dotfiles
COPY --chown=${SSH_USER}:${SSH_USER} dotfiles /home/${SSH_USER}/.dotfiles

View file

@ -1,8 +1,11 @@
# Always start tmux if it isn't yet.
if [ -z "$TMUX" ]
then
tmux attach -t default || tmux new -s default
fi
#if [ -z "$TMUX" ]
#then
# tmux attach -t default || tmux new -s default
#fi
# NVM
source /usr/share/nvm/init-nvm.sh
# Starship
eval "$(starship init zsh)"

View file

@ -1,26 +0,0 @@
FROM alpine:3 as build
WORKDIR /root
RUN apk --no-cache add curl tar
ARG VERSION=1.3.0
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT
# We have to override ARCH if amd64
# https://github.com/charmbracelet/glow/blob/b9e5d6b144b111ade70e30b7f31e1c46f79a7ec9/.goreleaser.yml#L33-L37
RUN if [[ "${TARGETARCH}" == "amd64" ]]; then export ARCH="x86_64"; else export ARCH="${TARGETARCH}"; fi \
&& curl -L -o glow.tar.gz \
"https://github.com/charmbracelet/glow/releases/download/v${VERSION}/glow_${VERSION}_${TARGETOS}_${ARCH}${TARGETVARIANT}.tar.gz"
RUN tar -xzvf glow.tar.gz
FROM alpine:3
LABEL maintainer="Tine <mentos1386> Jozelj <tine@tjo.space>"
LABEL org.opencontainers.image.source https://github.com/mentos1386/workspace
COPY --from=build /root/glow /usr/local/bin/glow
ENTRYPOINT /usr/local/bin/glow

View file

@ -4,8 +4,8 @@
template = "templates/actions/workspace.yaml.tmpl"
[templates."workspace-action".vars]
name = "workspace"
dockerfile = "Dockerfile"
name = "workspace-node"
dockerfile = "Dockerfile.node"
repository = "ghcr.io/mentos1386"
platforms = "linux/amd64,linux/arm64"
@ -26,10 +26,6 @@ version = "1.20.0"
name = "starship"
version = "0.47.0"
[[templates."package-action".vars.jobs]]
name = "glow"
version = "1.3.0"
[[templates."package-action".vars.jobs]]
name = "mosh"
version = "master"