Skip to content

Commit

Permalink
changes to multistage build for Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
niquerio committed Jun 6, 2023
1 parent c6b48ef commit 081f434
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-deploy-on-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
with:
image_name: ${{ vars.IMAGE_NAME }}
tag: ${{ github.event.release.tag_name }}
dockerfile: Dockerfile.prod
dockerfile: Dockerfile
secrets: inherit

deploy-production:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
with:
image_name: ${{ vars.IMAGE_NAME }}
tag: ${{ github.sha }}
dockerfile: Dockerfile.prod
dockerfile: Dockerfile
secrets: inherit

deploy-testing:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
with:
image_name: ${{ vars.IMAGE_NAME }}
tag: ${{ github.event.inputs.tag }}
dockerfile: Dockerfile.prod
dockerfile: Dockerfile
secrets: inherit

deploy-production:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/manual-deploy-unstable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
with:
image_name: ${{ vars.IMAGE_NAME }}
tag: ${{ github.event.inputs.tag }}
dockerfile: Dockerfile.prod
dockerfile: Dockerfile
secrets: inherit

deploy:
Expand Down
21 changes: 17 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
ARG RUBY_VERSION=3.2
FROM ruby:${RUBY_VERSION}
FROM ruby:3.2 AS development

ARG UNAME=app
ARG UID=1000
ARG GID=1000

LABEL maintainer="mrio@umich.edu"

RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends \
apt-transport-https

Expand All @@ -28,3 +25,19 @@ USER $UNAME
ENV BUNDLE_PATH /gems

WORKDIR /app

FROM development AS production

COPY --chown=${UID}:${GID} . /app
ENV BUNDLE_WITHOUT development:test

RUN --mount=type=secret,id=gh_package_read_token,uid=1000 \
read_token="$(cat /run/secrets/gh_package_read_token)" \
&& BUNDLE_RUBYGEMS__PKG__GITHUB__COM=${read_token} bundle install

RUN npm ci

RUN npm run build
RUN cp js/* public/bundles/

CMD ["bundle", "exec", "rackup", "-p", "4567", "--host", "0.0.0.0"]
44 changes: 0 additions & 44 deletions Dockerfile.prod

This file was deleted.

14 changes: 10 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
version: '3'
version: '3.8'

services:
web:
build: .
build:
context: .
target: development
ports:
- "4567:4567"
- "9394:9394"
Expand All @@ -22,14 +24,18 @@ services:
- 0.0.0.0

css:
build: .
build:
context: .
target: development
volumes:
- .:/app
- gem_cache:/gems
command: bundle exec ruby ./config/css-listener.rb

js:
build: .
build:
context: .
target: development
volumes:
- .:/app
- gem_cache:/gems
Expand Down

0 comments on commit 081f434

Please sign in to comment.