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

Minor Dockerfile changes (WORKDIR, user, cleanup) #1101

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
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
27 changes: 14 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@
#
# shared build/settings for all child images
###
FROM ruby:3.3.0-slim-bookworm AS base
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
ARG RUBY_VERSION=3.3.0
FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim-bookworm as base

ARG userid=309
SHELL ["/bin/bash", "-c"]
RUN groupadd -g $userid -r gi-bill-data-service && \
useradd -u $userid -r -g gi-bill-data-service -d /srv/gi-bill-data-service gi-bill-data-service
# Rails app lives here
WORKDIR /app

ARG USER_ID=309

RUN groupadd -g $USER_ID gi-bill-data-service && \
useradd -u $USER_ID -g gi-bill-data-service --create-home --shell /bin/bash gi-bill-data-service
RUN apt-get update -qq && apt-get install -y \
build-essential git curl wget libpq-dev dumb-init shared-mime-info nodejs cron file

RUN mkdir -p /srv/gi-bill-data-service/src && \
chown -R gi-bill-data-service:gi-bill-data-service /srv/gi-bill-data-service
WORKDIR /srv/gi-bill-data-service/src
RUN chown -R gi-bill-data-service:gi-bill-data-service /app

###
# development
Expand Down Expand Up @@ -62,7 +65,7 @@ ENV RAILS_ENV="production"
ENV PATH="/usr/local/bundle/bin:${PATH}"

COPY --from=builder $BUNDLE_APP_CONFIG $BUNDLE_APP_CONFIG
COPY --from=builder --chown=gi-bill-data-service:gi-bill-data-service /srv/gi-bill-data-service/src ./
COPY --from=builder --chown=gi-bill-data-service:gi-bill-data-service /app /app
USER gi-bill-data-service

ENTRYPOINT ["bash", "-c"]
Expand All @@ -78,19 +81,17 @@ FROM base AS production
ENV RAILS_ENV="production"
ENV PATH="/usr/local/bundle/bin:${PATH}"

RUN whoami

# Clone platform-va-ca-certificate and copy certs
WORKDIR /tmp
RUN git clone --depth 1 https://github.com/department-of-veterans-affairs/platform-va-ca-certificate && \
cp platform-va-ca-certificate/VA*.cer . && \
/bin/bash platform-va-ca-certificate/debian-ubuntu/install-certs.sh && \
rm -rf /tmp/*

WORKDIR /srv/gi-bill-data-service/src
WORKDIR /app

COPY --from=builder $BUNDLE_APP_CONFIG $BUNDLE_APP_CONFIG
COPY --from=builder --chown=gi-bill-data-service:gi-bill-data-service /srv/gi-bill-data-service/src ./
COPY --from=builder --chown=gi-bill-data-service:gi-bill-data-service /app /app
USER gi-bill-data-service

ENTRYPOINT ["/usr/bin/dumb-init", "--", "./docker-entrypoint.sh"]
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
target: development
image: "gibct:${DOCKER_IMAGE:-latest}"
volumes:
- ".:/srv/gi-bill-data-service/src/:cached"
- ".:/app/:cached"
- dev_bundle:/usr/local/bundle
ports:
- 3000:3000
Expand Down