Skip to content

Commit c52076a

Browse files
authored
Merge pull request #23 from atlp-rwanda/ft-docker-service-#187928765
Devops: eagle-ec-fe containerization with docker-#187928765
2 parents f306d90 + 2ee09ad commit c52076a

File tree

6 files changed

+161
-3
lines changed

6 files changed

+161
-3
lines changed

Diff for: .dockerignore

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Include any files or directories that you don't want to be copied to your
2+
# container here (e.g., local build artifacts, temporary files, etc.).
3+
#
4+
# For more help, visit the .dockerignore file reference guide at
5+
# https://docs.docker.com/go/build-context-dockerignore/
6+
7+
**/.classpath
8+
**/.dockerignore
9+
**/.env
10+
**/.git
11+
**/.gitignore
12+
**/.project
13+
**/.settings
14+
**/.toolstarget
15+
**/.vs
16+
**/.vscode
17+
**/.next
18+
**/.cache
19+
**/*.*proj.user
20+
**/*.dbmdl
21+
**/*.jfm
22+
**/charts
23+
**/docker-compose*
24+
**/compose.y*ml
25+
**/Dockerfile*
26+
**/node_modules
27+
**/npm-debug.log
28+
**/obj
29+
**/secrets.dev.yaml
30+
**/values.dev.yaml
31+
**/build
32+
**/dist
33+
LICENSE
34+
README.md

Diff for: Dockerfile

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use a specific version of Node Alpine as the base image.
2+
ARG NODE_VERSION=20.11.0
3+
4+
FROM node:${NODE_VERSION}-alpine as base
5+
6+
# Update npm to the latest version
7+
RUN npm install -g npm@latest
8+
9+
# Set the working directory inside the container.
10+
WORKDIR /eagles-ec-fe
11+
12+
# Copy package.json and package-lock.json files
13+
COPY package*.json ./
14+
15+
# Install dependencies
16+
RUN npm install --legacy-peer-deps
17+
18+
# Copy the rest of the application code
19+
COPY . .
20+
21+
# Expose the port the app runs on
22+
EXPOSE 5173
23+
24+
# Command to run the app
25+
CMD [ "npm", "run", "dev" ]

Diff for: README.Docker.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
### Building and running your application
2+
3+
When you're ready, start your application by running:
4+
`docker compose up --build`.
5+
6+
Your application will be available at http://localhost:5173.
7+
8+
### Deploying your application to the cloud
9+
10+
First, build your image, e.g.: `docker build -t myapp .`.
11+
If your cloud uses a different CPU architecture than your development
12+
machine (e.g., you are on a Mac M1 and your cloud provider is amd64),
13+
you'll want to build the image for that platform, e.g.:
14+
`docker build --platform=linux/amd64 -t myapp .`.
15+
16+
Then, push it to your registry, e.g. `docker push myregistry.com/myapp`.
17+
18+
Consult Docker's [getting started](https://docs.docker.com/go/get-started-sharing/)
19+
docs for more detail on building and pushing.
20+
21+
### References
22+
* [Docker's Node.js guide](https://docs.docker.com/language/nodejs/)

Diff for: README.md

+20-2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,24 @@ npm install
6262

6363
Write your test by creating a file with .test.tsx extetion under **test** directory.
6464

65-
```
6665

67-
```
66+
## Running it with Docker Image
67+
68+
## 1. Pull Docker Image:
69+
70+
```bash
71+
docker pull mugemanebertin/eagle-ec-fe:latest
72+
```
73+
74+
This command downloads the Docker image `mugemanebertin/eagle-ec-fe` from Docker Hub.
75+
76+
## 2. Run Docker Container:
77+
78+
```bash
79+
docker run -d --name eagle-ec-fe-container -p 5173:5173 mugemanebertin/eagle-ec-fe:latest
80+
```
81+
82+
This command starts a Docker container named `eagle-ec-fe-container`, mapping port `5173` on your host to port `5173` in the container. The `-d` flag runs the container in detached mode.
83+
84+
You can now access the Eagle E-commerce application by navigating to `http://localhost:5173` in your web browser.
85+

Diff for: docker-compose.yml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
version: '3.1'
2+
3+
services:
4+
web:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
8+
container_name: eagle-ec-fe-container
9+
image: mugemanebertin/eagle-ec-fe
10+
ports:
11+
- "5173:5173"
12+
env_file:
13+
- .env
14+
15+
backend:
16+
image: mugemanebertin/eagle_ec_be:latest
17+
container_name: eagle-ec-be-container
18+
ports:
19+
- "499:499"
20+
command: sh -c "npm run migrate && (npm run seed || true) && npm run dev"
21+
depends_on:
22+
- db
23+
- redis
24+
environment:
25+
- DB_CONNECTION=${DOCKER_DB_CONNECTION}
26+
- JWT_SECRET=${JWT_SECRET}
27+
- PORT=${PORT}
28+
- SMTP_HOST=${SMTP_HOST}
29+
- SMTP_PORT=${SMTP_PORT}
30+
- SMTP_USER=${SMTP_USER}
31+
- SMTP_PASS=${SMTP_PASS}
32+
- CLOUD_NAME=${CLOUD_NAME}
33+
- CLOUD_KEY=${CLOUD_KEY}
34+
- CLOUD_SECRET=${CLOUD_SECRET}
35+
- GOOGLE_CLIENT_ID=${GOOGLE_CLIENT_ID}
36+
- GOOGLE_CLIENT_SECRET=${GOOGLE_CLIENT_SECRET}
37+
- GOOGLE_CALLBACK_URL=${GOOGLE_CALLBACK_URL}
38+
- REDIS_HOST=redis
39+
- REDIS_PORT=6379
40+
41+
db:
42+
image: postgres:latest
43+
container_name: eagle-ec-db-container
44+
ports:
45+
- "5433:5432"
46+
environment:
47+
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
48+
- POSTGRES_USER=${POSTGRES_USER}
49+
- POSTGRES_DB=${POSTGRES_DB}
50+
volumes:
51+
- postgres_data:/var/lib/postgresql/data
52+
53+
redis:
54+
image: redis:latest
55+
ports:
56+
- "6379:6379"
57+
58+
volumes:
59+
postgres_data:

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"version": "0.0.0",
55
"type": "module",
66
"scripts": {
7-
"dev": "vite",
7+
"dev": "vite --host 0.0.0.0",
88
"build": "tsc && vite build",
99
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
1010
"preview": "vite preview",

0 commit comments

Comments
 (0)