Skip to content

Commit

Permalink
Configure Actions and Docker to build Node assets
Browse files Browse the repository at this point in the history
  • Loading branch information
tomodwyer authored and evansd committed Aug 23, 2024
1 parent ab8c2e7 commit 98e160e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@ jobs:
with:
python-version: "3.11"
install-just: true

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".node-version"
cache: "npm"
cache-dependency-path: package-lock.json

- name: Install node_modules
run: npm ci

- name: Build assets
run: npm run build

- name: Set up development environment
run: just devenv

Expand Down
28 changes: 28 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# syntax=docker/dockerfile:1.2
ARG NODE_VERSION=20

#################################################
#
# Create base image with python installed.
Expand Down Expand Up @@ -26,6 +28,28 @@ RUN --mount=type=cache,target=/var/cache/apt \
/root/docker-apt-install.sh /tmp/dependencies.txt


#################################################
#
# Create node image.
#
FROM node:${NODE_VERSION} AS node-builder

WORKDIR /usr/src/app

# copy just what npm ci needs
COPY package-lock.json package.json ./
RUN --mount=type=cache,target=/usr/src/app/.npm \
npm set cache /usr/src/app/.npm && \
npm ci

# just copy in the files `npm run build` needs
COPY vite.config.js tailwind.config.js postcss.config.js ./
COPY airlock/templates ./airlock/templates
COPY assets/templates ./assets/templates
COPY assets/src ./assets/src

RUN --mount=type=cache,target=./npm npm run build

##################################################
#
# Build image
Expand Down Expand Up @@ -83,6 +107,10 @@ WORKDIR /app
# are readable by all.
COPY --from=builder /opt/venv /opt/venv

# copy node assets over from node-builder image. These will have root:root ownership, but
# are readable by all.
COPY --from=node-builder /usr/src/app/assets/out /opt/assets

# Asset and staticfile management
#
# We support two dev environment side-by-side. Docker-based, which is the same
Expand Down

0 comments on commit 98e160e

Please sign in to comment.