Skip to content

Commit f7efc00

Browse files
committed
Add instructions on how to run emasser in Docker
1 parent 0e6ffb7 commit f7efc00

File tree

8 files changed

+79
-21
lines changed

8 files changed

+79
-21
lines changed

.dockerignore

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
# git
2-
.git
32
.gitignore
3+
Gemfile.lock
44
CHANGELOG.md
55

6+
# VS Code
7+
.vscode/
8+
9+
# doc
10+
doc/
11+
612
# ci
7-
.gitlab-ci.yml
13+
.github
14+
_config.yml
815

916
# code
1017
spec
11-
.env
18+
19+
#rubocop
20+
.rubocop.yml
21+
.rubocop_todo.yml

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111

1212
**/*.un~
1313

14-
emassing/test/test_example.zip
1514
.DS_Store
1615
.byebug_history
1716
.env
17+
key.pem
18+
client.pem
1819
*.gem

Dockerfile

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
11
# Buld from ruby 2.7.5 image
2-
FROM ruby:2.7
2+
FROM ruby:2.7.5
33

4-
# LABEL name="emasser" \
5-
# vendor="MTIRE" \
6-
# version="${EMASSER_VERSION}" \
7-
# release="1" \
8-
# url="https://github.com/mitre/emasser" \
9-
# description="Emasser is a command-line interface (CLI) that aims to automate routine business use-cases and provide utility surrounding the Enterprise Mission Assurance Support Service (eMASS) by leveraging its representational state transfer (REST) application programming interface (API)." \
10-
# docs="https://mitre.github.io/emasser/" \
11-
# run="docker run -d --name ${NAME} ${IMAGE} <args>"
4+
LABEL name="emasser" \
5+
vendor="MITRE" \
6+
version="${EMASSER_VERSION}" \
7+
release="1" \
8+
url="https://github.com/mitre/emasser" \
9+
description="Emasser is a command-line interface (CLI) that aims to automate routine business use-cases and provide utility surrounding the Enterprise Mission Assurance Support Service (eMASS) by leveraging its representational state transfer (REST) application programming interface (API)." \
10+
docs="https://mitre.github.io/emasser/" \
11+
run="docker run -d --name ${NAME} ${IMAGE} <args>"
1212

1313
# Set the base directory that will be used from now on
1414
WORKDIR /emasser
15+
VOLUME ["/emasser"]
1516

1617
# Copy - source (.) destination (.)
1718
COPY . .
1819

1920
# Don't install development or test dependencies
20-
# RUN bundle config set without 'development test'
21+
RUN bundle config set without 'development test'
2122
# Install dependency
23+
RUN gem install bundler -v '2.3.5'
2224
RUN bundle install
2325

2426
ENTRYPOINT ["bundle", "exec", "exe/emasser"]
25-
CMD ["-hello"]
27+
28+
CMD ["-h"]

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ PLATFORMS
9494
x64-mingw32
9595

9696
DEPENDENCIES
97-
bundler (~> 2.3.4)
97+
bundler (~> 2.3)
9898
bundler-audit (~> 0.7)
9999
byebug (~> 11.1.3)
100100
emass_client!
@@ -108,4 +108,4 @@ DEPENDENCIES
108108
yaml (~> 0.2.0)
109109

110110
BUNDLED WITH
111-
2.3.4
111+
2.3.5

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,49 @@ gem install emasser
8888
```
8989
bundle exec exe/emasser [command]
9090
```
91+
92+
## Using Docker
93+
**Note:** Before building the container:
94+
- Add a .env file containing the emasser required variables in the emasser source directory
95+
- Place the certificates (key.pem and client.pem) used to access the eMASS URL in the emasser source directory as well
96+
97+
### Build the Docker Container
98+
- Install and start Docker
99+
- Download emasser by running git clone https://github.com/mitre/emasser.git.
100+
- Navigate to the base folder where Dockerfile is located
101+
- Build the emasser container from a terminal window in the emasser source directory:
102+
```
103+
docker build -t emasser .
104+
```
105+
- To see the build output use:
106+
```
107+
docker build --no-cache --progress=plain -t emasser .
108+
```
109+
110+
### Run the emasser Docker Container (--rm remove the container when exit)
111+
- To run the emasser container use:
112+
```
113+
docker run --rm emasser
114+
```
115+
- To list all GET, POST, PUT, or DELETE commands use:
116+
```
117+
docker run --rm emasser get help
118+
```
119+
```
120+
docker run --rm emasser post help
121+
```
122+
```
123+
docker run --rm emasser put help
124+
```
125+
```
126+
docker run --rm emasser delete help
127+
```
128+
129+
### Delete (remove) the Docker Container
130+
```
131+
docker rmi -f emasser
132+
```
133+
91134
## Use
92135

93136
**Requirement 1 & 2: Authentication and Authorization:**

emasser.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
2929
spec.add_runtime_dependency 'thor', '~> 1.1.0'
3030
spec.add_runtime_dependency 'emass_client', '~> 1.0'
3131

32-
spec.add_development_dependency 'bundler', '~> 2.3.4'
32+
spec.add_development_dependency 'bundler', '~> 2.3'
3333
spec.add_development_dependency 'bundler-audit', '~> 0.7'
3434
spec.add_development_dependency 'byebug', '~> 11.1.3'
3535
spec.add_development_dependency 'rspec', '~> 3.10.0'

lib/emasser/cli.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ class CLI < Thor
2020
puts "emasser version: #{Emasser::VERSION}".green
2121
exit
2222
elsif ARGV[0].to_s.include? 'hello'
23-
print "Hello #{ENV['USERNAME']} - enjoy using emasser!".cyan
23+
user_name = ENV['USERNAME'] || 'rookie'
24+
print "Hello #{user_name} - enjoy using emasser!".cyan
2425
exit
2526
end
2627

lib/emasser/delete.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def self.exit_on_failure?
4747
end
4848

4949
# Delete a POAM -----------------------------------------------------------
50-
desc 'remove', 'Add one or many POA&M items in a system'
50+
desc 'remove', 'Delete one or many POA&M items in a system'
5151
long_desc Help.text(:poam_del_mapper)
5252

5353
# Required parameters/fields
@@ -110,7 +110,7 @@ def self.exit_on_failure?
110110
true
111111
end
112112

113-
desc 'remove', 'Remove one or many artifacts in a system'
113+
desc 'remove', 'Delete one or many artifacts in a system'
114114
long_desc Help.text(:artifact_del_mapper)
115115

116116
# Required parameters/fields

0 commit comments

Comments
 (0)