Skip to content

Commit

Permalink
FIN-459 - PIE-1157 - Implement Docker Container Best Practices
Browse files Browse the repository at this point in the history
* Docker USER directive added to Service
* make test feature added

This change needs to be tested before considered good for production.
The app will be running as user "appuser" instead as root, we need to make sure there are not side effects due this change.
  • Loading branch information
claudiomll committed Jan 31, 2024
1 parent 828b0ee commit 2eeeb7d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,9 @@ RUN bundle config --local set without 'development test' \
&& bundle config --local deployment true \
&& bundle install --jobs 20 --retry 5

RUN adduser --disabled-password -u 1001 appuser \
&& chown -R appuser:appuser /app

USER appuser:appuser
ENV RACK_ENV production
CMD ["bundle", "exec", "ruby", "fomotograph.rb", "-p", "4567"]
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ export
all: build

test:
@echo "Nothing to test..."
docker-compose up -d --build && sleep 10
# docker-compose exec test curl http://app:4567/healthcheck
docker-compose exec test curl http://app:4567/products.json -o /tmp/test1
docker-compose exec test jq '.' /tmp/test1
docker-compose exec test curl http://app:4567/erasurez -o /tmp/test2
docker-compose exec test jq '.' /tmp/test2
docker-compose down

build:
docker build -t $(SERVICE_NAME) .
Expand Down
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: '3'
services:
app:
build:
context: .
ports:
- "4567:4567"
test:
image: cimg/base:2024.01
command: sleep 1000

0 comments on commit 2eeeb7d

Please sign in to comment.