Skip to content

Commit

Permalink
Updated Dockerfile to create non-root user "aact" and switch to this …
Browse files Browse the repository at this point in the history
…user. Cleaned up file by removing unused comments.
  • Loading branch information
Javier-Jimenez-18 committed Oct 10, 2023
1 parent 9894e9b commit a1fd647
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
FROM ruby:2.7.7

# Create user and set ownership and permissions as required
RUN adduser -D aact && chown -R aact /app
# ... copy application files
USER aact
ENTRYPOINT ["/app"]

RUN sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt bullseye-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
# RUN sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
RUN wget --no-check-certificate --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -

RUN apt-get update -qq && apt-get install -y nodejs postgresql-client telnet vim zip cron graphviz wget

RUN mkdir /app
Expand All @@ -19,10 +11,16 @@ COPY Gemfile.lock /app/Gemfile.lock
RUN gem install bundler -v 1.17.3
RUN bundle install

# Create non-root user and set ownership and permissions as required
RUN adduser --disabled-password aact && chown -R aact /app

COPY . /app

RUN ln -s /config/connections.yml /app/config/connections.yml

# Switch to the user
USER aact

EXPOSE 3000

CMD ["bundle", "exec", "rails", "server", "-b" "0.0.0.0"]
CMD ["bundle", "exec", "rails", "server", "-b" "0.0.0.0"]

0 comments on commit a1fd647

Please sign in to comment.