Skip to content

Commit

Permalink
Merge branch 'main'
Browse files Browse the repository at this point in the history
  • Loading branch information
damccull committed Aug 17, 2023
2 parents 585bd48 + 00905d4 commit b0b3b52
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.238.0/containers/rust/.devcontainer/base.Dockerfile

# [Choice] Debian OS version (use bullseye on local arm64/Apple Silicon): buster, bullseye
ARG VARIANT="buster"
FROM mcr.microsoft.com/vscode/devcontainers/rust:${VARIANT}

# [Optional] Uncomment this section to install additional packages.
RUN apt-get update && \
export DEBIAN_FRONTEND=noninteractive && \
apt-get -y install --no-install-recommends \
clang \
lld \
neovim\
postgresql-client \
&& rm -rf /var/lib/apt/lists/*

USER 1000
ENV HOME /home/vscode

# Install cargo-binstall
#RUN mkdir -p /usr/local/cargo/bin
RUN wget -qO - "https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz" | tar zxvf - -C /usr/local/cargo/bin
# Install some cargo tools
RUN cargo binstall -y cargo-deny
RUN cargo binstall -y cargo-edit
RUN cargo binstall -y cargo-whatfeatures
RUN cargo binstall -y cargo-nextest

# Can't use binstall due to unique requirements
RUN cargo install sqlx-cli --no-default-features --features rustls,postgres

# Setup neovim
RUN mkdir -p $HOME/.config/nvim && \
echo "\
set number\n\
set relativenumber\n\
set expandtab\n\
set shiftwidth=4\n\
set tabstop=4\n\
set softtabstop=4\n\
"\
> $HOME/.config/nvim/init.vim

# Install Act tool to run GH actions locally
RUN curl -s https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash
47 changes: 47 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.238.0/containers/rust
{
"name": "ocieguide Rust and Postgres",
"dockerComposeFile": "docker-compose.yml",
"service": "devcontainer",
"workspaceFolder": "/workspace/ocieguide",
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
"lldb.executable": "/usr/bin/lldb",
// VS Code don't watch files under ./target
"files.watcherExclude": {
"**/target/**": true
},
"rust-analyzer.checkOnSave.command": "clippy"
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"vadimcn.vscode-lldb",
"mutantdino.resourcemonitor",
"rust-lang.rust-analyzer",
"tamasfe.even-better-toml",
"serayuzgur.crates",
"vscode-icons-team.vscode-icons",
"Gruntfuggly.todo-tree",
"aeschli.vscode-css-formatter",
"heaths.vscode-guid",
"mohsen1.prettify-json",
"redhat.vscode-yaml"
]
}
},
// 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": "SKIP_DOCKER=true cargo xtask postgres && cargo xtask redis",
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode",
"features": {
"docker-in-docker": "latest",
"git": "latest"
}
}
32 changes: 32 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: '3.8'

services:
devcontainer:
user: 1000:1000
build:
context: ..
dockerfile: .devcontainer/Dockerfile
args:
VARIANT: "bullseye"
volumes:
- ..:/workspace/ocieguide/:cached

command: sleep infinity
network_mode: service:db

db:
image: postgres:latest
restart: unless-stopped
volumes:
- postgres-data:/var/lib/postgresql/data
hostname: postgres
environment:
POSTGRES_DB: ocieguide
POSTGRES_USER: postgres
POSTGRES_PASS: password
POSTGRES_HOST_AUTH_METHOD: trust
ports:
- 5432:5432

volumes:
postgres-data: null

0 comments on commit b0b3b52

Please sign in to comment.