Skip to content

Instantly share code, notes, and snippets.

@jcarley
Last active March 30, 2026 08:31
Show Gist options
  • Select an option

  • Save jcarley/a72275195c631d209883babfb8a7a740 to your computer and use it in GitHub Desktop.

Select an option

Save jcarley/a72275195c631d209883babfb8a7a740 to your computer and use it in GitHub Desktop.
My C++ Docker based dev environment.
export SHELL='/bin/bash'
export LS_OPTIONS='--color=auto'
eval "`dircolors`"
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -l'
alias l='ls $LS_OPTIONS -lA'
version: "3"
services:
shell:
build: .
image: devshell:latest
working_dir: /project
volumes:
- $PWD:/project
FROM node:7.9.0
RUN apt-get update && apt-get install -y build-essential wget curl libroot-core-dev vim
ADD bashrc /root/.bashrc
CMD "/bin/bash"
# Project folder structure for a sample application
#
# --program_root
# |-- include
# |-- src
# | |-- account
# | | |-- account.cpp
# | | `-- account.h
# | `-- program.cpp
# |-- CPPLINT.cfg
# |-- Makefile
#
# Usage:
# make - builds the project
# make clean - cleans up the build folder
#
# the name of the resulting binary
TARGET_EXEC = program
# project folders
SRC_DIRS ?= ./src
BUILD_DIR ?= ./build
INC_DIR ?= ./include
MITIEDIR = mitie/mitielib
DLIBDIR = mitie/dlib
# find all the source files
SRCS := $(shell find $(SRC_DIRS) -name *.cpp)
# the object files
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
# concat all include folders
INC_DIRS := $(shell find $(INC_DIR) -type d)
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
# flags
CPPFLAGS ?= $(INC_FLAGS) -MMD -MP -I$(MITIEDIR)/include -I$(DLIBDIR)
CXXFLAGS = -std=c++14 -fPIC -W -O3 -Wall -Wextra -Wno-ctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-include-dirs -Woverloaded-virtual -Wredundant-decls -Wsign-promo -Wstrict-overflow=5 -Wswitch -Wundef -Wno-unused -Wnon-virtual-dtor -Wno-float-equal
LDFLAGS = $(MITIEDIR)/libmitie.a -lpthread
CC = g++
# link object files into resulting binary
$(BUILD_DIR)/$(TARGET_EXEC): $(OBJS) $(MITIEDIR)
@echo Linking $@ with flags: $(LDFLAGS)
@$(CC) $(OBJS) -o $@ $(LDFLAGS)
@echo Build Complete
.PHONY: $(MITIEDIR)
$(MITIEDIR):
$(MAKE) -C $(MITIEDIR)
# compile c++ source into object files
$(BUILD_DIR)/%.cpp.o: %.cpp
@echo Compiling $<
@$(MKDIR_P) $(dir $@)
$(CC) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@
# remove the build folder
clean:
@echo Removing binaries...
$(RM) -r $(BUILD_DIR)
cleanmitie:
@echo Removing mitie binaries...
$(MAKE) -C $(MITIEDIR) clean
recompile: clean
$(MAKE)
all: cleanmitie recompile
MITIE-models-v0.2.tar.bz2:
curl -LO https://github.com/mit-nlp/MITIE/releases/download/v0.4/MITIE-models-v0.2.tar.bz2
models: MITIE-models-v0.2.tar.bz2
tar -xjf MITIE-models-v0.2.tar.bz2
MKDIR_P ?= mkdir -p
.PHONY: all build clean cleanmitie recompile
#!/usr/bin/env bash
docker-compose run --rm shell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment