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

Assets container #171

Merged
merged 1 commit into from
Apr 5, 2024
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
24 changes: 23 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,25 @@ jobs:
- test
runs-on: ubuntu-latest
steps:
- id: time
run: |
echo "time=$(TZ=UTC date +%Y%m%d%H%M%S)" >> $GITHUB_OUTPUT
- id: meta
name: Docker meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository_owner }}/guildbook
tags: |
type=raw,value={{sha}}-{{date 'YYYYMMDDHHmmss'}}
type=raw,value={{sha}}-${{ steps.time.outputs.time }}
- id: meta-assets
name: Docker meta for assets
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository_owner }}/guildbook-assets
tags: |
type=raw,value={{sha}}-${{ steps.time.outputs.time }}
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v2
with:
Expand All @@ -54,6 +65,17 @@ jobs:
password: ${{ github.token }}
- uses: docker/build-push-action@v5
with:
target: app
push: ${{ github.ref == 'refs/heads/master' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- uses: docker/build-push-action@v5
with:
target: assets
push: ${{ github.ref == 'refs/heads/master' }}
tags: ${{ steps.meta-assets.outputs.tags }}
labels: ${{ steps.meta-assets.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
14 changes: 10 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ARG RUBY=public.ecr.aws/sorah/ruby:3.2-bookworm
ARG RUBYDEV=public.ecr.aws/sorah/ruby:3.2-dev-bookworm
ARG NODE=public.ecr.aws/docker/library/node:lts-bookworm-slim
ARG NGINX=public.ecr.aws/docker/library/nginx:1.24

###
FROM $RUBYDEV as bundle
Expand All @@ -26,7 +27,12 @@ COPY . .
RUN npm run build

###
FROM $RUBY
FROM $NGINX as assets

COPY --from=webpack /app/public/ /usr/share/nginx/html/

###
FROM $RUBY as app

RUN apt-get update -qq && \
apt-get install -y dumb-init && \
Expand All @@ -35,8 +41,8 @@ RUN apt-get update -qq && \
WORKDIR /app

COPY . .
COPY --from=bundle /app/vendor /app/vendor
COPY --from=bundle /app/.bundle /app/.bundle
COPY --from=webpack /app/node_modules /app/node_modules
COPY --from=bundle /app/vendor/ /app/vendor/
COPY --from=bundle /app/.bundle/ /app/.bundle/
COPY --from=webpack /app/public/assets/assets-manifest.json /app/public/assets/assets-manifest.json

ENTRYPOINT ["/app/docker/entrypoint.sh"]
Loading