Skip to content

Commit

Permalink
install Node dependencies in docker image using a multi-stage build
Browse files Browse the repository at this point in the history
  • Loading branch information
osma committed Sep 20, 2023
1 parent 131b61d commit d4ba887
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ components
plugins/*
composer.phar
composer.lock
tests/jena-fuseki*
node_modules
.vagrant
.project
.DS_Store
Expand Down
13 changes: 12 additions & 1 deletion dockerfiles/Dockerfile.ubuntu
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Stage 0: install Node dependencies
FROM node:18-alpine AS npm-installer

WORKDIR /usr/src/app
COPY package.json ./

# install node.js dependencies e.g. Vue (but not the development dependencies)
RUN npm install --omit=dev

# Stage 1: runtime image
FROM ubuntu:22.04

LABEL maintainer="National Library of Finland"
Expand All @@ -6,7 +16,6 @@ LABEL description="A Docker image for Skosmos with Apache httpd."

ARG DEBIAN_FRONTEND=noninteractive

# git is necessary for some composer packages e.g. davidstutz/bootstrap-multiselect
RUN apt-get update && apt-get install -y \
apache2 \
curl \
Expand Down Expand Up @@ -76,6 +85,8 @@ RUN php composer.phar install --no-dev --no-autoloader
COPY . /var/www/html
RUN php composer.phar install --no-dev

# install Node modules (from npm-installer stage)
COPY --from=npm-installer /usr/src/app/node_modules /var/www/html/node_modules

# Configure Skosmos
COPY dockerfiles/config/config-docker.ttl /var/www/html/config.ttl
Expand Down

0 comments on commit d4ba887

Please sign in to comment.