Skip to content

Commit 395c700

Browse files
committed
Add Docker Compose support.
1 parent d9ef27d commit 395c700

File tree

5 files changed

+52
-10
lines changed

5 files changed

+52
-10
lines changed

.env

Lines changed: 0 additions & 4 deletions
This file was deleted.

Dockerfile

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,30 @@
1+
# Use an official Node.js runtime as a parent image
12
FROM node:21.7.2
23

4+
# Set the working directory inside the container
35
WORKDIR /root/bem-web
4-
COPY . /root/bem-web
5-
RUN cd /root/bem-web
6-
RUN npm i
76

7+
# Copy the package.json and package-lock.json files first to leverage Docker cache
8+
COPY package.json ./
9+
COPY package-lock.json ./
10+
11+
# Install dependencies
12+
RUN npm install
13+
14+
# Copy the rest of the application code
15+
COPY . .
16+
17+
# Ensure the environment variables are available at build time (optional)
18+
# ARG REACT_APP_API_BASE_URL
19+
# ARG REACT_APP_API_PORT
20+
# ARG REACT_APP_ENV
21+
# ARG SPECIES_LINK_KEY
22+
23+
# Build the app for production
24+
RUN npm run build
25+
26+
# Expose the port on which the app will run
827
EXPOSE 3000
928

10-
CMD ["npm", "start"]
29+
# Start the application
30+
CMD ["npm", "start"]

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,8 @@ Certifique de possuir [node v21.7.2](https://nodejs.org/en/download)
1515
## Contêiner
1616
Certifique de possuir [Docker](https://docs.docker.com/desktop/)
1717
1. Clonar o repositório
18-
2. Acessar o diretório da aplicação e executar o comando `docker build -t bem-web .`
19-
3. Com a imagem criada inicialize o contêiner com o comando `docker run -d -p 3000:3000 bem-web`
18+
19+
> [!IMPORTANT]
20+
> Renomeie o arquivo `RENAME_TO_DOTENV.md` para `.env`
21+
22+
2. Inicialize o container com `docker compose up --build`

RENAME_TO_DOTENV.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
REACT_APP_API_BASE_URL=http://127.0.0.1
2+
REACT_APP_API_PORT=80
3+
REACT_APP_ENV=dev
4+
SPECIES_LINK_KEY=VjSPRSjDJKAdk8ojl3PR

docker-compose.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: '3.8'
2+
3+
services:
4+
bem-web:
5+
build: .
6+
ports:
7+
- "3000:3000"
8+
environment:
9+
REACT_APP_API_BASE_URL: ${REACT_APP_API_BASE_URL}
10+
REACT_APP_API_PORT: ${REACT_APP_API_PORT}
11+
REACT_APP_ENV: ${REACT_APP_ENV}
12+
SPECIES_LINK_KEY: ${SPECIES_LINK_KEY}
13+
env_file:
14+
- .env
15+
volumes:
16+
- .:/root/bem-web
17+
- /root/bem-web/node_modules
18+
stdin_open: true
19+
tty: true

0 commit comments

Comments
 (0)