Skip to content

Commit 612eee1

Browse files
Add Docker containers to generate a local ionic server
1 parent 5036758 commit 612eee1

3 files changed

Lines changed: 50 additions & 2 deletions

File tree

.dockerignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.git
2+
.gitignore
3+
Dockerfile
4+
.dockerignore
5+
node_modules
6+
platforms
7+
resources
8+
plugins
9+
docs
10+
Aplicaciones
11+
www

Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Use a Node.js base image
2+
FROM node:22-alpine
3+
4+
# Set the working directory inside the container
5+
WORKDIR /app
6+
7+
# Copy all files
8+
COPY . .
9+
10+
# Install ionic dependence
11+
RUN npm install -g @ionic/cli
12+
13+
# Install dependencies
14+
RUN npm install
15+
16+
# Expose the port Ionic serves on (default is 8100)
17+
EXPOSE 8100
18+
19+
# Command to run when the container starts
20+
CMD ["ionic", "serve", "--host", "0.0.0.0", "--port", "8100"]

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Frontend project that allows you to manage simple tasks by storing information i
1212
|Android Studio |`21.0.4`|
1313
|Java JDK |`20`|
1414
|Gradle |`9.0.0`|
15+
|Docker ||
1516

1617
## Important note
1718

@@ -25,7 +26,7 @@ To run the frontend project, follow these steps:
2526

2627
- After cloning the repository, install the node dependencies using the command `npm install` inside the `ionic-sqlite-tasks` project folder. If an error occurs, add the --force option.
2728

28-
- Run the command `ng serve` to start the server. By default, the url `http://localhost:8100` is used.
29+
- Run the command `ionic serve` to start the server. By default, the url `http://localhost:8100` is used.
2930

3031
- In the browser, you can emulate how it would look on a mobile phone, but in this case, the database would not work, as it is a native dependency. That is why local storage is used in this test to perform tests from a PC.
3132

@@ -47,4 +48,20 @@ Verify that the mobile phone connected via USB is recognized as a device by runn
4748

4849
- If there is only one device connected in the list above, you can run the command `ionic cordova run android --device`. But if there is more than one device connected, run the command `ionic cordova run android --target=<device_id>`. <device_id> is the ID generated in the list in the previous point. If an error occurs, use the **--verbose** option at the end of the command to display detailed information about the execution, the error, and its cause.
4950

50-
- When you run the above command, the application will be compiled and installed on your mobile phone, eliminating the need to compile the project, find the apk file, and transfer it to your mobile phone to install the application. When you install the application for the first time, you will be asked to authorize the installation of the application on your mobile phone. You must select the OK button each time it is displayed for installation.
51+
- When you run the above command, the application will be compiled and installed on your mobile phone, eliminating the need to compile the project, find the apk file, and transfer it to your mobile phone to install the application. When you install the application for the first time, you will be asked to authorize the installation of the application on your mobile phone. You must select the OK button each time it is displayed for installation.
52+
53+
## Docker Instructions
54+
55+
To run the frontend project in a Docker container, follow these steps:
56+
57+
- Clone the project, either with the command git clone `https://github.com/dev-shelvin-batista/ionic-sqlite-tasks.git` or using a GitHub graphical tool.
58+
59+
- Access the folder in a command terminal using the cd command.
60+
61+
- The project already has a Dockerfile that generates the image to create the container. Just create the image with the `docker build -t ionic-sqlite-tasks .` command.
62+
63+
- Create the container from the image created by running the `docker run --rm -p 8100:8100 ionic-sqlite-tasks` command.
64+
65+
- After running the above command, the container will be active and you will be able to access the frontend project from the host with the URL `http://localhost:8100/`.
66+
67+
- You can change the port to be used on the host by modifying the port in the **docker run** command in the **-p** option.

0 commit comments

Comments
 (0)