Skip to content

Commit 5c30d5f

Browse files
committed
Add new build arg
1 parent bb77dc5 commit 5c30d5f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

Dockerfile

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
FROM node:16.13.0-alpine
22
ARG API_URL
3+
ARG MAPBOX_ACCESS_TOKEN
34

45
# Based on https://nodejs.org/en/docs/guides/nodejs-docker-webapp/
56

@@ -18,9 +19,9 @@ COPY babel.config.js ./
1819
# Bundle app source
1920
COPY src ./src
2021

21-
# Run the scripts defined in package.json
22+
# Run the scripts defined in package.json using build arguments
2223
RUN npm install && \
23-
API_URL=$API_URL npm run build
24+
API_URL=$API_URL MAPBOX_ACCESS_TOKEN=$MAPBOX_ACCESS_TOKEN npm run build
2425

2526
EXPOSE 3001
2627

webpack.client.common.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
const path = require('path')
2-
const dotenv = require('dotenv').config()
2+
require('dotenv').config()
33
const HtmlWebpackPlugin = require('html-webpack-plugin')
44
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
55
const webpack = require('webpack')
66

77
const outputDirectory = 'dist/public'
88
const apiUrl = typeof process.env.API_URL !== 'undefined' ? process.env.API_URL : 'http://localhost:3001/api/v1'
9+
const mapboxAccessToken = typeof process.env.MAPBOX_ACCESS_TOKEN !== 'undefined' ? process.env.MAPBOX_ACCESS_TOKEN : 'MAPBOX_ACCESS_TOKEN missing'
910

1011
module.exports = {
1112
entry: {
@@ -29,7 +30,7 @@ module.exports = {
2930
}),
3031
new webpack.DefinePlugin({
3132
'process.env.API_URL': JSON.stringify(apiUrl),
32-
'process.env': JSON.stringify(dotenv.parsed)
33+
'process.env.MAPBOX_ACCESS_TOKEN': JSON.stringify(mapboxAccessToken)
3334
})
3435
],
3536
output: {

0 commit comments

Comments
 (0)