Skip to content

Commit

Permalink
Devcontainer (#63)
Browse files Browse the repository at this point in the history
* Add universal devcontainer image, install R.

* Add "postCreateCommand": "make"
  • Loading branch information
kasbohm authored May 16, 2024
1 parent 53bf498 commit 137cd3d
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM mcr.microsoft.com/vscode/devcontainers/universal:1.7.5-linux

# Set environment variables to avoid interactive prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive

# # Update and install necessary packages
RUN apt-get update && \
apt-get install -y \
software-properties-common \
wget \
gnupg2 \
lsb-release \
apt-transport-https \
ca-certificates \
libcurl4-openssl-dev \
libssl-dev \
libxml2-dev

# # Install R
RUN apt-get install -y r-base

# # Install PHP
# RUN add-apt-repository ppa:ondrej/php && \
# apt-get update && \
# apt-get install -y php7.4

# # Install Lighttpd
# RUN apt-get update && \
# apt-get install -y lighttpd
27 changes: 27 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "Universal with PostgreSQL",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",

// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
// "ghcr.io/shyim/devcontainers-features/php:latest": {
// "version": "7.4",
// "extensionsExtra": "xdebug redis"
// }
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// This can be used to network with other containers or the host.
// "forwardPorts": [5000, 5432],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "make"

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
35 changes: 35 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: '3.8'

services:
app:
build:
context: ..
dockerfile: .devcontainer/Dockerfile

volumes:
- ../..:/workspaces:cached

# Overrides default command so things don't shut down after the process ends.
command: sleep infinity

# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
network_mode: service:db

# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)

db:
image: postgres:latest
restart: unless-stopped
volumes:
- postgres-data:/var/lib/postgresql/data
environment:
POSTGRES_USER: postgres
POSTGRES_DB: postgres
POSTGRES_PASSWORD: postgres

# Add "forwardPorts": ["5432"] to **devcontainer.json** to forward PostgreSQL locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)

volumes:
postgres-data:

0 comments on commit 137cd3d

Please sign in to comment.