Dockerize
To deploy an Angular website using Docker, follow these steps:
Steps
Create a Dockerfile in the root of your Angular project.
# Stage 1: Build the Angular application
FROM node:20.5.1 as node
WORKDIR /app
COPY . .
RUN npm install --force
RUN npm run build --prod
# Stage 2: Serve the application using Nginx
FROM nginx:alpine
COPY --from=node /app/angular-web /usr/share/nginx/html
# Build the docker container
docker build -t my-angular-web-app .
# Run the docker container now
docker run -d -p 80:80 my-angular-app
Deploying Using WinSCP and PuTTY
I currently use WinSCP for file transfer and PuTTY for running commands. Here's how you can do it:
Transfer Files with WinSCP
WinSCP is a tool that lets you transfer files between your computer and a remote server.
-
Download and Install WinSCP:
- Download it from WinSCP's official website.
-
Connect to Your Server:
- Open WinSCP and enter your server's hostname (or IP address), username, and password.
- Make sure to use the default SFTP protocol.
- Also PPK (PuTTY Private Key) is mandatory.
-
Transfer Your Files:
- On the left side of WinSCP, you'll see your local files. On the right side, you'll see your server files.
- After creating .tar, file we drag the file into our remote server.
Run Commands with PuTTY
PuTTY is a tool that lets you remotely access your server's command line interface.
-
Download and Install PuTTY:
- Download it from PuTTY's official website.
-
Connect to Your Server:
- Open PuTTY and enter your server's hostname (or IP address) and port (usually 22).
- Click "Open" to start the session.
- Log in with your username and password.
Kill the running processes
# view the running processes
docker ps
# stop the desired container
docker stop -p containerId
Kill the running images
# First, view the running images
docker images
# Next, stop the desired image container id:
docker rmi containerId # -f if it does not let you remove it.
Load the tar, unextract it and deploy
# load the tar
docker load -i /path/to/my-image.tar
# run the desired container
docker run -dp 80:80 project my-image .
Creating build for React Native
Navigate to android directory.
# first clean
./gradlew clean
# then create apk
./gradlew assembleRelease
The APK will now be created at android/app/build/outputs/apk/release/*.apk
Add more commands as soon as I find something that's really important.