-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
83 lines (70 loc) · 2.46 KB
/
Makefile
File metadata and controls
83 lines (70 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
.PHONY: build test test-file shell update all
# Docker image name
IMAGE_NAME = openc_bot_test
# Project directory (to be mounted in container)
PROJECT_DIR = $(shell pwd)
# SSH mount argument - simple version that just mounts .ssh directory
SSH_MOUNT_ARGS = -v $(HOME)/.ssh:/root/.ssh:ro
# Default target
all: test
# Build Docker image with Ruby 2.6.3
build:
@echo "Building Docker image with Ruby 2.6.3..."
docker build -t $(IMAGE_NAME) -f Dockerfile .
# Update dependencies in the Docker container
update:
@echo "Updating dependencies in Docker container..."
docker run --rm \
-v $(PROJECT_DIR):/app \
$(SSH_MOUNT_ARGS) \
$(IMAGE_NAME) bash -c "bundle update"
# Run tests in the Docker container
test: build
@echo "Running tests in Docker container..."
docker run --rm \
-v $(PROJECT_DIR):/app \
$(SSH_MOUNT_ARGS) \
$(IMAGE_NAME) bash -c "bundle update && bundle install && bundle exec rspec"
# Run a specific test file
test-file: build
@echo "Running test file: $(FILE)"
docker run --rm \
-v $(PROJECT_DIR):/app \
$(SSH_MOUNT_ARGS) \
$(IMAGE_NAME) bash -c "bundle update && bundle install && bundle exec rspec $(FILE)"
# Open a shell in the Docker container
shell: build
@echo "Opening shell in Docker container..."
docker run --rm -it \
-v $(PROJECT_DIR):/app \
$(SSH_MOUNT_ARGS) \
$(IMAGE_NAME) bash
# Start a Ruby console in the Docker container
console: build
@echo "Starting IRB in Docker container..."
docker run --rm -it \
-v $(PROJECT_DIR):/app \
$(SSH_MOUNT_ARGS) \
$(IMAGE_NAME) bash -c "bundle update && bundle install && bundle exec irb -r ./lib/openc_bot.rb"
# Clean up Docker images
clean:
@echo "Removing Docker image..."
-docker rmi $(IMAGE_NAME)
# Run a custom command in the Docker container
# Usage: make run CMD="bundle exec rake some_task"
run: build
@echo "Running command: $(CMD)"
docker run --rm \
-v $(PROJECT_DIR):/app \
$(SSH_MOUNT_ARGS) \
$(IMAGE_NAME) bash -c "bundle update && bundle install && $(CMD)"
# Help target
help:
@echo "Available targets:"
@echo " make build - Build the Docker image with Ruby 2.6.3"
@echo " make test - Run all tests in the Docker container"
@echo " make test-file FILE=path/to/test.rb - Run a specific test file"
@echo " make shell - Open a shell in the Docker container"
@echo " make console - Start a Ruby console with openc_bot loaded"
@echo " make run CMD=\"command\" - Run a custom command in the container"
@echo " make clean - Remove the Docker image"