Skip to content

Commit

Permalink
Merge pull request #23 from nventive/chore/docker-setup
Browse files Browse the repository at this point in the history
Docker setup
  • Loading branch information
KarmineSH authored Oct 3, 2024
2 parents 9d178cb + 893a4d7 commit 3319fff
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The goal is to standardize how we build web projects in the company.
## Getting Started

- Install [Yarn](https://yarnpkg.com/getting-started/install)
- Go inside the frontend directory. Run `yarn install` and `yarn dev` to start the project.
- View [frontend Readme](/frontend/README.md) to start the project

## Packages

Expand Down
11 changes: 11 additions & 0 deletions frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

Run `yarn install` and `yarn dev` in this directory to launch the react project in your browser

## Windows

To run on windows, use docker.

1. Set VITE_DOCKER to true in .env
2. Run `docker-compose up --build --no-recreate -d` in this directory to create the container.
3. Run `docker exec -it vite_docker sh` to log into the container.
4. Run `corepack enable` to use the latest version of yarn.
5. Make sure that yarn is set to version 4.5 with `yarn -v`, and run `yarn set version stable` if it isn't.
6. Run `yarn` and `yarn dev` to launch the react project in your browser.

## Update locale files

Pull key:value from google sheets to create json file.
Expand Down
16 changes: 16 additions & 0 deletions frontend/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: "3.4"
services:
vite_docker:
image: node:20.11.1
container_name: vite_docker
env_file:
- .env
entrypoint: /bin/sh
ports:
- 8000:8000
working_dir: /srv/app
volumes:
- type: bind
source: ./
target: /srv/app
tty: true
1 change: 1 addition & 0 deletions frontend/example.env
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ VITE_ENV=local
VITE_VERSION_NUMBER=v0.0.1
VITE_API_URL=<API_URL>
VITE_GA_TRACKING_ID=<GA_TRACKING_ID>
VITE_DOCKER=false
14 changes: 10 additions & 4 deletions frontend/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig, loadEnv } from "vite";
import { defineConfig, loadEnv, ServerOptions } from "vite";
import react from "@vitejs/plugin-react";
import { pigment } from "@pigment-css/vite-plugin";
import theme from "./src/themes/theme";
Expand All @@ -7,6 +7,14 @@ import path from "path";
export default ({ mode }: { mode: string }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };

const serverOptions: ServerOptions = {
port: Number(process.env.VITE_PORT),
};
if (process.env.VITE_DOCKER === "true") {
serverOptions.host = true;
serverOptions.watch = { usePolling: true };
}

return defineConfig({
plugins: [
react(),
Expand All @@ -18,9 +26,7 @@ export default ({ mode }: { mode: string }) => {
build: {
sourcemap: process.env.VITE_GENERATE_SOURCEMAP === "true",
},
server: {
port: Number(process.env.VITE_PORT),
},
server: serverOptions,
define: {
__ENV__: JSON.stringify(process.env.VITE_ENV),
__API_URL__: JSON.stringify(process.env.VITE_API_URL),
Expand Down

0 comments on commit 3319fff

Please sign in to comment.