Skip to content

Commit

Permalink
Merge pull request #105 from Tauffer-Consulting/fix/dockerfile-dev-fo…
Browse files Browse the repository at this point in the history
…r-k8s

Fix/dockerfile dev for k8s
  • Loading branch information
vinicvaz authored Oct 13, 2023
2 parents ec769df + 59d124f commit d3a4c33
Showing 12 changed files with 334 additions and 17 deletions.
4 changes: 2 additions & 2 deletions docker-compose-dev.yaml
Original file line number Diff line number Diff line change
@@ -361,8 +361,8 @@ services:
container_name: domino-frontend
command: yarn start
environment:
- VITE_API_ENV=local
- VITE_DOMINO_DEPLOY_MODE=local-compose
- API_ENV=local
- DOMINO_DEPLOY_MODE=local-compose
ports:
- 3000:3000
volumes:
2 changes: 2 additions & 0 deletions frontend/.env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
API_ENV="local"
DOMINO_DEPLOY_MODE="local-compose"
8 changes: 7 additions & 1 deletion frontend/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -10,6 +10,9 @@ COPY package.json yarn.lock ./
# Install dependencies
RUN yarn install --production --frozen-lockfile && yarn cache clean

RUN npx pkg ./node_modules/@import-meta-env/cli/bin/import-meta-env.js \
-o import-meta-env -y

# Copy the rest of the source code
COPY . .

@@ -21,12 +24,15 @@ FROM nginx:1.25.2

# Copy the build output from the previous stage
COPY --from=build /app/build /usr/share/nginx/html
COPY --from=build /app/import-meta-env /usr/share/nginx/html

# Configure nginx to serve the app
COPY nginx.conf /etc/nginx/conf.d/default.conf

COPY entrypoint.sh /usr/share/nginx/html

# Expose port 80
EXPOSE 80

# Run NGINX in the foreground
CMD ["nginx", "-g", "daemon off;"]
ENTRYPOINT ["sh","/usr/share/nginx/html/entrypoint.sh"]
9 changes: 9 additions & 0 deletions frontend/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
set -e

echo "API_ENV=$API_ENV" >> .env.production
echo "DOMINO_DEPLOY_MODE=$DOMINO_DEPLOY_MODE" >> .env.production

/usr/share/nginx/html/import-meta-env -x .env.production -p /usr/share/nginx/html/index.html || exit 1

nginx -g "daemon off;"
3 changes: 3 additions & 0 deletions frontend/index.html
Original file line number Diff line number Diff line change
@@ -6,6 +6,9 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />

<script src="https://use.fontawesome.com/releases/v5.15.4/js/all.js" data-auto-a11y="true"></script>
<script>
globalThis.import_meta_env = JSON.parse('"import_meta_env_placeholder"')
</script>

<!-- Fonts to support Material Design -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
3 changes: 3 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
@@ -8,6 +8,8 @@
"dependencies": {
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"@import-meta-env/cli": "^0.6.6",
"@import-meta-env/unplugin": "^0.4.10",
"@material-ui/core": "^4.12.4",
"@mui/icons-material": "^5.11.0",
"@mui/lab": "^5.0.0-alpha.113",
@@ -23,6 +25,7 @@
"cross-env": "^7.0.3",
"date-fns": "^2.30.0",
"dayjs": "^1.11.7",
"dotenv": "^16.3.1",
"elkjs": "^0.8.2",
"localforage": "^1.10.0",
"react": "^18.2.0",
2 changes: 1 addition & 1 deletion frontend/src/config/environment.config.ts
Original file line number Diff line number Diff line change
@@ -15,6 +15,6 @@ export interface IEnvironment {
*/
export const environment: IEnvironment = {
NODE_ENV: import.meta.env.NODE_ENV as INodeEnv,
API_ENV: import.meta.env.VITE_API_ENV as IApiEnv,
API_ENV: import.meta.env.API_ENV as IApiEnv,
USE_MOCK: !!import.meta.env.VITE_USE_MOCK,
};
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ const defaultSettingsData: IWorkflowSettings = {
};

const storageSourceOptions =
import.meta.env.VITE_DOMINO_DEPLOY_MODE === "local-compose"
import.meta.env.DOMINO_DEPLOY_MODE === "local-compose"
? [
{
label: "None",
2 changes: 1 addition & 1 deletion frontend/src/services/config/localForage.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as localForage from "localforage";
import localForage from "localforage";

localForage.config({
name: "Domino",
8 changes: 7 additions & 1 deletion frontend/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import viteTsconfigPaths from "vite-tsconfig-paths";
import importMetaEnv from "@import-meta-env/unplugin";
import svgrPlugin from "vite-plugin-svgr";

// https://vitejs.dev/config/
@@ -9,7 +10,12 @@ export default defineConfig({
host: '0.0.0.0',
port: 3000,
},
plugins: [react(), viteTsconfigPaths(), svgrPlugin()],
plugins: [
react(),
viteTsconfigPaths(),
svgrPlugin(),
importMetaEnv.vite({ example: ".env.production" })
],
build: {
outDir: "build",
}
Loading

0 comments on commit d3a4c33

Please sign in to comment.