From 45ab0efbe57c1f80f4aa99f2edb60acee3ee526e Mon Sep 17 00:00:00 2001 From: Stephen Dolan Date: Fri, 23 Sep 2022 02:02:31 -0400 Subject: [PATCH] Add Dockerfile to deployment options (#626) * Add Dockerfile to deployment options * Update deployment.md --- bridgetown-website/src/_docs/deployment.md | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/bridgetown-website/src/_docs/deployment.md b/bridgetown-website/src/_docs/deployment.md index 457389b8e..a581388a6 100644 --- a/bridgetown-website/src/_docs/deployment.md +++ b/bridgetown-website/src/_docs/deployment.md @@ -54,6 +54,39 @@ Rsync is similar to scp except it can be faster as it will only send changed parts of files as opposed to the entire file. You can learn more about using rsync in the [Digital Ocean tutorial](https://www.digitalocean.com/community/tutorials/how-to-use-rsync-to-sync-local-and-remote-directories-on-a-vps). +### Docker + +Many modern hosting solutions support deploying a `Dockerfile`. Building a Bridgetown site for one of these services is as easy as adding this file to a `Dockerfile` in the root directory of your project: + +```Dockerfile +# Build frontend JS and CSS assets using ESbuild +FROM node:alpine as asset_builder +ENV BRIDGETOWN_ENV=production +WORKDIR /assets +COPY . . +RUN yarn install +RUN yarn run esbuild + +# Generate your site content as HTML +FROM ruby:alpine as bridgetown_builder +ENV BRIDGETOWN_ENV=production +WORKDIR /app +RUN apk add --no-cache build-base +RUN gem install bundler -N +RUN gem install bridgetown -N +COPY . . +RUN bundle install +COPY --from=asset_builder /assets/output output/ +COPY --from=asset_builder /assets/.bridgetown-cache .bridgetown-cache/ +RUN ./bin/bridgetown build + +# Serve your site in a tiny production container, which serves on port 8043. +FROM pierrezemb/gostatic +COPY --from=bridgetown_builder /app/output /srv/http/ +``` + +A `Dockerfile` like this could be used, for example, to [deploy a static website to Fly.io](https://fly.io/docs/languages-and-frameworks/static/). + ### GitLab Pages [GitLab pages](https://docs.gitlab.com/ee/user/project/pages/) can host static websites. Create a repository on GitLab,