Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

./aapb test and format commands #2496

Merged
merged 1 commit into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ COPY Gemfile Gemfile.lock ./

RUN bundle install

# COPY . .

EXPOSE 3000

CMD rake jetty:clean && rake jetty:config && rake jetty:start && bundle exec rake db:migrate RAILS_ENV=development && bundle exec rails s -b 0.0.0.0
32 changes: 24 additions & 8 deletions aapb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ COMMANDS:\n\n
\t b | build \t build the docker image\n
\t c | cmd \t run a bash command with the docker image\n
\t d | dev \t start a development server\n
\t f | format \t run the rubocop formatter\n
\t h | help \t prints this help text\n
\t t | test \t run the test suite\n
"

DEV_CMD="docker run -it -p 3000:3000 -v $(pwd):/usr/src/app/ aapb"
DOCKER_RUN="docker run -it --rm --name aapb"
DOCKER_EXEC="docker exec -it"
VOLUME_MOUNT="-v $(pwd):/usr/src/app/"
PORT_MOUNT="-p 3000:3000"

if [ -z $1 ]; then
echo -e $HELP
Expand All @@ -25,16 +30,27 @@ elif [ $1 = "build" -o $1 = "b" ]; then
docker build -t aapb . "$@"

elif [ $1 = "cmd" -o $1 = "c" ]; then
shift
if [ -z $1 ]; then
$DEV_CMD bash
else $DEV_CMD "$@"
fi
shift
CMD="$DOCKER_EXEC aapb"
if [ -z $1 ]; then
$CMD bash
else $CMD "$@"
fi

elif [ $1 = "dev" -o $1 = "d" ]; then
shift
$DEV_CMD "$@"
$DOCKER_RUN $PORT_MOUNT $VOLUME_MOUNT aapb "$@"

elif [ $1 = "test" -o $1 = "t" ]; then
shift
$DOCKER_EXEC aapb bundle exec rspec "$@"

else echo -e $HELP
elif [ $1 = "format" -o $1 = "f" ]; then
shift
$DOCKER_EXEC aapb rubocop --auto-correct "$@"

else
echo "Unrecognezed command: $@"
echo -e $HELP

fi