Skip to content

Commit

Permalink
chore: Add devcontainer configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
bartventer committed Jun 20, 2024
1 parent c3a0b33 commit 98cf77b
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 4 deletions.
22 changes: 22 additions & 0 deletions .devcontainer/build/.devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "Docstoregen Devcontainer",
"build": {
"dockerfile": "Dockerfile",
"context": "."
},
"features": {
"ghcr.io/bartventer/arch-devcontainer-features/go": {
"golangciLintVersion": "none",
"installGoReleaser": true
},
"ghcr.io/bartventer/arch-devcontainer-features/docker-in-docker": {}
},
"customizations": {
"vscode": {
"extensions": [
"github.vscode-github-actions"
]
}
},
"remoteUser": "vscode"
}
6 changes: 6 additions & 0 deletions .devcontainer/build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM ghcr.io/bartventer/devcontainer-images/base-archlinux:latest

LABEL org.opencontainers.image.source="https://github.com/bartventer/docstore-gen"
LABEL org.opencontainers.image.authors="Bart Venter <bartventer@outlook.com>"
LABEL org.opencontainers.image.title="docstore-gen"
LABEL org.opencontainers.image.description="Development container for docstore-gen"
8 changes: 8 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "Docstoregen Devcontainer",
"image": "ghcr.io/bartventer/docstore-gen/devcontainer:latest",
"mounts": [
"source=/tmp/.X11-unix,target=/tmp/.X11-unix,type=bind,consistency=cached",
"source=${localEnv:HOME}/.vscode-server,target=/home/vscode/.vscode-server-insiders/extensions,type=bind,consistency=cached"
]
}
42 changes: 42 additions & 0 deletions .github/workflows/devcontainer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Devcontainer Build

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0' # Every Sunday at 00:00
push:
branches:
- master
paths:
- '.devcontainer/build/**'

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Dependencies
run: yarn global add @devcontainers/cli

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build, Push and Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./scripts/devcontainer.sh
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,5 @@
# Environment variables
.env

# Devcontainer
.devcontainer

# Temp directory generated during testing
__temp__*
__temp__*
14 changes: 14 additions & 0 deletions scripts/devcontainer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

set -euo pipefail

echo "🚀 Building devcontainer..."

devcontainer build \
--log-level debug \
--workspace-folder .devcontainer/build \
--image-name ghcr.io/bartventer/docstore-gen/devcontainer:latest \
--platform linux/amd64 \
--push

echo "🎉 OK. Successfully built devcontainer."

0 comments on commit 98cf77b

Please sign in to comment.