Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
xxl4tomxu98 committed Oct 1, 2024
0 parents commit e9e0f0d
Show file tree
Hide file tree
Showing 7 changed files with 485 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM mcr.microsoft.com/devcontainers/python:1-3.12-bookworm
# install poetry for python dependencies
RUN python3 -m pip install poetry~=1.8.3
# enable bash completion for git
# RUN echo "source /usr/share/bash-completion/completions/git" >> ~/.bashrc

WORKDIR /workspaces/my_ansible

COPY poetry.lock pyproject.toml ./

RUN chown -R vscode:vscode /workspaces

USER vscode

RUN poetry install

# symlink poetry env to ~/venv
RUN VN=$(poetry env list | head -n 1 | cut -d ' ' -f 1) \
&& ln -s ~/.cache/pypoetry/virtualenvs/$VN ~/venv
44 changes: 44 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"name": "My-Ansible-2024",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
// "image": "mcr.microsoft.com/devcontainers/python:1-3.12-bookworm"
"build": {
"dockerfile": "Dockerfile",
"context": ".."
},
//"image": "ghcr.io/xxl4tomxu98/ansible:latest",

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "pip3 install --user -r requirements.txt",

// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
"redhat.ansible",
"tamasfe.even-better-toml"
],
"settings": {
"ansible.python.interpreterPath": "/venv/bin/python3",
"python.defaultInterpreterPath": "/venv/bin/python3",

"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
}
}
}
}
},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
"remoteUser": "root"
}
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for more information:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://containers.dev/guide/dependabot

version: 2
updates:
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: weekly
53 changes: 53 additions & 0 deletions .github/workflows/build-devcontainer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
name: Build devcontainer

on:
push:
branches: [main]
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-devcontainer:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Login to container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

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

- name: Extract metadata
id: metadata
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest
type=sha
- name: Build/push container image
uses: docker/build-push-action@v5
with:
cache-from: type=gha
cache-to: type=gha
context: .
push: true
file: .devcontainer/Dockerfile
labels: ${{ steps.metadata.outputs.labels }}
tags: ${{ steps.metadata.outputs.tags }}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is a simple Ansible Devcontainer repo
Loading

0 comments on commit e9e0f0d

Please sign in to comment.