Skip to content

Commit 0a4a060

Browse files
[Dockerfile] Server static generated files in alpine nginx container (#56)
1 parent 21102ab commit 0a4a060

2 files changed

Lines changed: 26 additions & 10 deletions

File tree

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.github/
2+
.nuxt/
3+
.yarn/
4+
node_modules/

Dockerfile

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,29 @@
1-
FROM node:lts
1+
FROM node:lts AS builder
22

3-
# Clone and move into directory
4-
RUN git clone https://github.com/IntellectualSites/schematic-web.git /app
3+
# Set working directory
54
WORKDIR /app
65

7-
# Install dependencies
8-
RUN yarn install
6+
# Install dependencies without lock file
7+
COPY package.json /app/package.json
8+
RUN yarn install --silent
99

10-
# Build application
11-
RUN yarn build
10+
# Get all remaining files
11+
COPY . /app
12+
13+
# Generate static files
14+
RUN yarn run generate
15+
16+
FROM nginx:stable-alpine
17+
18+
# Copy dist files (generated) from builder layer into this (lightweight) nginx image
19+
COPY --from=builder /app/dist /usr/share/nginx/html
1220

1321
# Expose the port
14-
EXPOSE 3000
22+
EXPOSE 80
1523

16-
# Start the app
17-
CMD ["yarn", "start"]
24+
LABEL \
25+
org.opencontainers.image.vendor="IntellectualSites" \
26+
org.opencontainers.image.title="schematic-web" \
27+
org.opencontainers.image.description="Frontend for arkitektonika" \
28+
org.opencontainers.image.url="https://github.com/IntellectualSites" \
29+
org.opencontainers.image.source="https://github.com/IntellectualSites/schematic-web"

0 commit comments

Comments
 (0)