Skip to content

Commit

Permalink
build: small refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
tobybellwood committed Jul 9, 2024
1 parent 0688a69 commit 683c52a
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 39 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/docker-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,23 @@ jobs:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Cache
uses: actions/cache@v3
id: cache
with:
path: |
yarn-cache
key: cache-${{ hashFiles('**/yarn.lock') }}
-
name: inject cache into docker
uses: reproducible-containers/[email protected]
with:
cache-map: |
{
"yarn-cache": "/home/.yarn"
}
skip-extraction: ${{ steps.cache.outputs.cache-hit }}
-
name: Build and push
uses: docker/build-push-action@v5
Expand All @@ -99,6 +116,8 @@ jobs:
build-args: |
"LAGOON_VERSION=${{ env.VERSION }}"
"BUILD=${{ env.BUILD }}"
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Node builder image
FROM uselagoon/node-20-builder:latest AS dev
FROM uselagoon/node-20-builder:latest AS local-dev

# Copy only what we need into the image
COPY ./src/ /app/src
Expand Down Expand Up @@ -27,15 +27,15 @@ ENV KEYCLOAK_API=$KEYCLOAK_API
FROM uselagoon/node-20:latest AS prod-builder

# Copy the whole /app folder from dev
COPY --from=dev /app/ /app/
COPY --from=local-dev /app/ /app/

# Build app
RUN --mount=type=cache,target=/home/.yarn YARN_CACHE_FOLDER=/home/.yarn yarn run build
# Remove any node_modules in DevDependencies not needed for production
RUN --mount=type=cache,target=/home/.yarn YARN_CACHE_FOLDER=/home/.yarn yarn workspaces focus -A --production

# Build the final production image
FROM uselagoon/node-20:latest
FROM uselagoon/node-20:latest AS prod

# Copy the whole /app folder from prod-builder
COPY --from=prod-builder /app/ /app/
Expand Down
27 changes: 27 additions & 0 deletions docker-compose.local-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: '3.2'

services:
ui:
build:
context: .
target: local-dev
dockerfile: Dockerfile
labels:
lagoon.type: none
command: yarn run dev
volumes:
- ./src:/app/src
- ./.env.defaults:/app/.env.defaults
- ./.env.schema:/app/.env.schema
- ./package.json:/app/package.json
ports:
- '3003:3003'
networks:
- default
environment:
LAGOON_ROUTE: http://lagoon-ui.docker.amazee.io
LAGOON_UI_TOURS_ENABLED: true
NODE_ENV: development
GRAPHQL_API: "${GRAPHQL_API:-http://0.0.0.0:3000/graphql}"
KEYCLOAK_API: "${KEYCLOAK_API:-http://0.0.0.0:8088/auth}"

41 changes: 5 additions & 36 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
version: '3.2'

x-lagoon-project:
# Lagoon project name (leave `&lagoon-project` when you edit this)
&lagoon-project lagoon-ui

x-environment: &default-environment
LAGOON_PROJECT: *lagoon-project
GRAPHQL_API: "${GRAPHQL_API:-http://0.0.0.0:3000/graphql}"
KEYCLOAK_API: "${KEYCLOAK_API:-http://0.0.0.0:8088/auth}"

services:
ui:
build:
context: .
target: prod
dockerfile: Dockerfile
labels:
lagoon.type: node
Expand All @@ -22,31 +14,8 @@ services:
networks:
- default
environment:
LAGOON_ROUTE: &default-url http://lagoon-ui.docker.amazee.io
LAGOON_ROUTE: http://lagoon-ui.docker.amazee.io
LAGOON_UI_TOURS_ENABLED: false
LAGOON_ENVIRONMENT_TYPE: production
<<: *default-environment

dev:
build:
context: .
target: dev
dockerfile: Dockerfile
labels:
lagoon.type: none
command: yarn run dev
volumes:
- ./src:/app/src
- ./.env.defaults:/app/.env.defaults
- ./.env.schema:/app/.env.schema
- ./package.json:/app/package.json
ports:
- '3003:3003'
networks:
- default
environment:
LAGOON_ROUTE: http://lagoon-dev.docker.amazee.io
LAGOON_UI_TOURS_ENABLED: true
LAGOON_ENVIRONMENT_TYPE: development
<<: *default-environment

NODE_ENV: production
GRAPHQL_API: "${GRAPHQL_API:-https://api.lagoon.amazeeio.cloud/graphql}"
KEYCLOAK_API: "${KEYCLOAK_API:-https://keycloak.amazeeio.cloud/auth}"

0 comments on commit 683c52a

Please sign in to comment.