Skip to content

Commit 8015050

Browse files
committed
build: update docker build workflow
1 parent 17843f4 commit 8015050

File tree

7 files changed

+62
-21
lines changed

7 files changed

+62
-21
lines changed

.dockerignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,8 @@ README.md
99
node_modules
1010
build
1111

12+
node_modules
13+
build
14+
1215
# Envs
13-
**/.env.local
16+
**/.env.local

.github/workflows/docker-image.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ jobs:
9696
with:
9797
context: .
9898
platforms: linux/amd64,linux/arm64
99-
# platforms: linux/amd64
10099
build-args: |
101100
"LAGOON_VERSION=${{ env.VERSION }}"
102101
"BUILD=${{ env.BUILD }}"

Dockerfile

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,44 @@
11
# Node builder image
2-
FROM uselagoon/node-20-builder:latest AS builder
2+
FROM uselagoon/node-20-builder:latest AS dev
33

4-
COPY . /app/
4+
# Copy only what we need into the image
5+
COPY ./src/ /app/src
6+
COPY server.js .
7+
COPY plugins.json .
8+
COPY package.json .
9+
COPY yarn.lock .
10+
COPY tour.json .
11+
COPY tourHash.js .
512

6-
RUN yarn install --network-timeout 300000
13+
# Upgrade the yarn version in /app to the most recent to take advantage of new features
14+
RUN yarn set version berry
715

8-
9-
# Node service image
10-
FROM uselagoon/node-20:latest
16+
# use a buildkit cache for yarn - this is reused in later steps
17+
RUN --mount=type=cache,target=/home/.yarn YARN_CACHE_FOLDER=/home/.yarn yarn install --network-timeout 300000
1118

1219
ARG LAGOON_VERSION
20+
ARG GRAPHQL_API
21+
ARG KEYCLOAK_API
1322
ENV LAGOON_VERSION=$LAGOON_VERSION
23+
ENV GRAPHQL_API=$GRAPHQL_API
24+
ENV KEYCLOAK_API=$KEYCLOAK_API
1425

15-
# Copy the node_modules from node builder
16-
COPY --from=builder /app/node_modules /app/node_modules
26+
# Use an intermediate image to build and trim the production image
27+
FROM uselagoon/node-20:latest AS prod-builder
1728

18-
# Copying files from ui service
19-
COPY . /app/
29+
# Copy the whole /app folder from dev
30+
COPY --from=dev /app/ /app/
2031

21-
ARG KEYCLOAK_API
22-
ENV KEYCLOAK_API=$KEYCLOAK_API
32+
# Build app
33+
RUN --mount=type=cache,target=/home/.yarn YARN_CACHE_FOLDER=/home/.yarn yarn run build
34+
# Remove any node_modules in DevDependencies not needed for production
35+
RUN --mount=type=cache,target=/home/.yarn YARN_CACHE_FOLDER=/home/.yarn yarn workspaces focus -A --production
2336

24-
ARG GRAPHQL_API
25-
ENV GRAPHQL_API=$GRAPHQL_API
37+
# Build the final production image
38+
FROM uselagoon/node-20:latest
2639

27-
# Build app
28-
RUN yarn run build
40+
# Copy the whole /app folder from prod-builder
41+
COPY --from=prod-builder /app/ /app/
2942

3043
EXPOSE 3000
3144
CMD ["yarn", "start"]

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@ These values can also be updated in `docker-compose.yml`.
2121

2222
### Docker
2323

24-
Note: Within `docker-compose.yml` `GRAPHQL_API` & `KEYCLOAK_API` will need to be set to
24+
Docker Compose is configured to deploy two services locally:
25+
- dev (0.0.0.0:3003): A live updating development build, using volumes to mount from /src and rebuild-on the fly
26+
- ui (0.0.0.0:3000): A built, production ready implementation of the code in the repo
27+
Lagoon will only deploy the "ui" version into a cluster.
2528

29+
Note: Within `docker-compose.yml` `GRAPHQL_API` & `KEYCLOAK_API` will need to be set to
2630
```
2731
GRAPHQL_API: "${GRAPHQL_API:-https://api.lagoon.amazeeio.cloud/graphql}"
2832
KEYCLOAK_API: "${KEYCLOAK_API:-https://keycloak.amazeeio.cloud/auth}"

docker-compose.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,24 @@ services:
2121
dockerfile: Dockerfile
2222
labels:
2323
lagoon.type: node
24+
command: yarn run start
25+
ports:
26+
- '3000:3000'
27+
networks:
28+
- default
29+
environment:
30+
LAGOON_ROUTE: &default-url http://lagoon-ui.docker.amazee.io
31+
LAGOON_UI_TOURS_ENABLED: false
32+
LAGOON_ENVIRONMENT_TYPE: production
33+
<<: *default-environment
34+
35+
dev:
36+
build:
37+
context: .
38+
target: dev
39+
dockerfile: Dockerfile
40+
labels:
41+
lagoon.type: none
2442
command: yarn run dev
2543
volumes:
2644
- ./src:/app/src
@@ -32,4 +50,8 @@ services:
3250
networks:
3351
- default
3452
environment:
53+
LAGOON_ROUTE: http://lagoon-dev.docker.amazee.io
54+
LAGOON_UI_TOURS_ENABLED: true
55+
LAGOON_ENVIRONMENT_TYPE: development
3556
<<: *default-environment
57+

src/pages/_app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import Tour from '../tours/Tour';
2727
import { TourContextProvider } from '../tours/TourContext';
2828

2929
const { LAGOON_UI_TOURS_ENABLED } = getConfig().publicRuntimeConfig;
30-
const tourEnabled = LAGOON_UI_TOURS_ENABLED === 'enabled';
30+
const tourEnabled = LAGOON_UI_TOURS_ENABLED === 'true';
3131

3232
// lazy load animation features
3333
const loadFeatures = () => import('components/common/features').then(res => res.default);

src/tours/TourControlBtn.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { TourContext, TourContextType } from './TourContext';
1313
*/
1414

1515
const { LAGOON_UI_TOURS_ENABLED } = getConfig().publicRuntimeConfig;
16-
const tourEnabled = LAGOON_UI_TOURS_ENABLED === 'enabled';
16+
const tourEnabled = LAGOON_UI_TOURS_ENABLED === 'true';
1717

1818
const TourControlBtn = () => {
1919
let skipped,

0 commit comments

Comments
 (0)