Skip to content

Commit

Permalink
chore: Update Dockerfile and docker-compose files for local developme…
Browse files Browse the repository at this point in the history
…nt and fix compose files and vite config files for web
  • Loading branch information
waveyboym committed Jul 21, 2024
1 parent ccb2988 commit c484ced
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion frontend/occupi-web/Dockerfile.local.dev
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ COPY . .
RUN npm run build

# Expose the port the app runs on
EXPOSE 4001
EXPOSE 4000

# Command to run the executable
CMD ["npm", "run", "preview"]
2 changes: 1 addition & 1 deletion frontend/occupi-web/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
context: .
dockerfile: Dockerfile.dev
ports:
- "4001:5173"
- "4001:4173"
networks:
- webnet
volumes:
Expand Down
4 changes: 2 additions & 2 deletions frontend/occupi-web/docker-compose.local.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
container_name: occupi-web-dev
build:
context: .
dockerfile: Dockerfile.dev
dockerfile: Dockerfile.local.dev
ports:
- "4001:5173"
- "4000:4173"
restart: on-failure:5
2 changes: 1 addition & 1 deletion frontend/occupi-web/docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
context: .
dockerfile: Dockerfile.prod
ports:
- "4000:5173"
- "4000:4173"
networks:
- webnet
volumes:
Expand Down
14 changes: 8 additions & 6 deletions frontend/occupi-web/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ import react from "@vitejs/plugin-react";
import path from "path";
import tsconfigPaths from "vite-tsconfig-paths";
import fs from 'fs';
import mkcert from 'vite-plugin-mkcert';

// Define paths to the certificates
let keyPath = '';
let certPath = '';

if (process.env.NODE_ENV === 'development') {
keyPath = path.resolve(__dirname, 'cert.key');
certPath = path.resolve(__dirname, 'cert.crt');
} else if (process.env.NODE_ENV === 'preview-dev') {
if (process.env.NODE_ENV === 'preview-dev') {
keyPath = '/etc/letsencrypt/live/dev.occupi.tech/privkey.pem';
certPath = '/etc/letsencrypt/live/dev.occupi.tech/fullchain.pem';
} else if (process.env.NODE_ENV === 'preview-prod') {
Expand All @@ -21,7 +19,9 @@ if (process.env.NODE_ENV === 'development') {

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react(), tsconfigPaths()],
plugins: [react(), tsconfigPaths(), mkcert({
hosts: ['localhost', 'dev.occupi.tech', 'app.occupi.tech'],
})],


resolve: {
Expand All @@ -36,9 +36,11 @@ export default defineConfig({
usePolling: true,
interval: 1000, // Adjust the interval if needed
},
https: process.env.NODE_ENV === 'production' ? {} : {
https: process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'preview' || process.env.NODE_ENV === 'development' ? {} : {
key: fs.readFileSync(keyPath),
cert: fs.readFileSync(certPath),
},
host: '0.0.0.0',
port: 4173,
},
});

0 comments on commit c484ced

Please sign in to comment.