Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request #834 from navikt/dev/push-til-cdn
Browse files Browse the repository at this point in the history
Dev/push til cdn
  • Loading branch information
jstnhlj authored Jan 20, 2023
2 parents d8dadc0 + 2960057 commit 02b27b8
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 58 deletions.
47 changes: 25 additions & 22 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,36 @@ env:
IMAGE_BASE: ghcr.io/${{github.repository}}/veientilarbeid

jobs:
test-build-and-push:
name: Build, cdn-upload, docker push
build-cdn-docker:
name: Build, CDN & Docker
runs-on: ubuntu-latest

# permissions:
# contents: 'read'
# packages: 'write'
# id-token: 'write'
permissions:
contents: 'read'
packages: 'write'
id-token: 'write'

steps:
- uses: 'actions/checkout@v1'
name: Checkout
# - uses: 'actions/setup-node@v3'
# with:
# node-version: '18'
# cache: 'npm'
# - name: 'Install dependencies'
# run: 'npm ci'
# - name: 'Build application'
# run: 'npm run build:cdn'
#
# - name: cdn-upload
# uses: navikt/frontend/actions/cdn-upload/v1@main
# with:
# cdn-team-name: paw
# source: ./dist/js
# destination: '/aia/'

- uses: 'actions/setup-node@v3'
with:
node-version: '18'
cache: 'npm'

- name: 'Install dependencies'
run: 'npm ci'

- name: 'Build application'
run: 'REACT_APP_MICRO="true" REACT_APP_VERSION_HASH=${{ github.sha }} REACT_APP_BUILD_TIMESTAMP=$(date +"%Y-%m-%dT%H:%M:%S") npm run build:cdn'

- name: cdn-upload
uses: navikt/frontend/actions/cdn-upload/v1@main
with:
cdn-team-name: paw
source: ./dist/js
destination: '/aia/'

- name: Lag tag for image
run: echo "TAG=$(git log -1 --pretty='%ad_%h' --date=format:'%Y%m%d%H%M%S')" >> $GITHUB_ENV
Expand All @@ -57,7 +60,7 @@ jobs:
deploy-dev:
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/dev')
name: Deploy til dev
needs: test-build-and-push
needs: build-cdn-docker
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
Expand Down
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ENV CI=true
WORKDIR /source

# npm run build har blitt kjørt på github før docker build
# RUN cp -r /source/dist /cdn
RUN cp -r /source/dist /build

RUN npm ci

Expand All @@ -20,13 +20,11 @@ ENV REACT_APP_BUILD_TIMESTAMP=$REACT_APP_BUILD_TIMESTAMP
RUN npm run build:demo
RUN cp -r /source/dist /demo

ENV REACT_APP_MICRO="true"
RUN npm run build:cdn

FROM nginx:1.23-alpine
COPY nginx.conf /etc/nginx/nginx.conf

COPY --from=node-builder /source/dist /usr/share/nginx/html/esm
COPY --from=node-builder /build /usr/share/nginx/html/esm
COPY --from=node-builder /demo /usr/share/nginx/html/demo

RUN cp /usr/share/nginx/html/demo/mockServiceWorker.js /usr/share/nginx/html/mockServiceWorker.js
Expand Down
18 changes: 0 additions & 18 deletions app.json

This file was deleted.

10 changes: 6 additions & 4 deletions src/url.js → src/url.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { erProduksjon } from './utils/app-state-utils';

function getEnvironment() {
let environment = 'development';
if (process.env.NODE_ENV === 'production') {
environment = 'production';
if (erProduksjon()) {
return 'production';
}
return environment;

return 'development';
}

const MINE_DAGPENGER_URL = {
Expand Down
11 changes: 1 addition & 10 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import svgr from 'vite-plugin-svgr';
import EnvironmentPlugin from 'vite-plugin-environment';

const getEnvironmentOpts = () => ({
NODE_ENV: process.env.NODE_ENV || 'development',
REACT_APP_VERSION_HASH: process.env.REACT_APP_VERSIOM_HASH || '',
REACT_APP_BUILD_TIMESTAMP: process.env.REACT_APP_BUILD_TIMESTAMP || '',
REACT_APP_MICRO: process.env.REACT_APP_MICRO || '',
Expand Down Expand Up @@ -38,14 +37,6 @@ const getPlugins = () => {

const getConfig = () => ({
plugins: getPlugins(),
build: {
lib: {
entry: resolve(__dirname, 'src/main.tsx'),
name: 'veientilarbeid',
formats: ['es'],
fileName: () => `bundle.js`,
},
},
server: {
port: 3002,
},
Expand All @@ -61,7 +52,7 @@ const getCdnConfig = () => ({
},
preserveEntrySignatures: 'exports-only',
output: {
entryFileNames: 'aia.[hash].js',
entryFileNames: 'js/aia.[hash].js',
format: 'esm',
},
},
Expand Down

0 comments on commit 02b27b8

Please sign in to comment.