Menggunakan Firebase Dan Node JS 14 Di Docker Ubuntu
Sebagai pengguna mac mini saya mengalami kesulitan untuk menggunakan firebase, oleh karena itu saya menggunakan docker untuk menjalankan firebase di dalam OS Ubuntu, begini caranya
1. Siapkan docker file dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Download base image ubuntu 22.04 | |
FROM ubuntu:22.04 | |
RUN rm /bin/sh && ln -s /bin/bash /bin/sh | |
# LABEL about the custom image | |
LABEL maintainer="tasmananhar@gmail.com" | |
LABEL version="0.1" | |
LABEL description="This is a custom Docker Image for firebase" | |
# Disable Prompt During Packages Installation | |
ARG DEBIAN_FRONTEND=noninteractive | |
# Update Ubuntu Software repository | |
RUN apt update | |
RUN apt upgrade -y | |
RUN apt -y install sudo | |
RUN apt -y install curl | |
RUN curl -sL https://deb.nodesource.com/setup_14.x | sudo bash - | |
RUN cat /etc/apt/sources.list.d/nodesource.list | |
RUN sudo apt -y install nodejs | |
# RUN sudo apt -y install npm | |
RUN npm install -g firebase-tools@10.1.0 | |
# Expose Port for the Application | |
EXPOSE 9005 |
docker build --tag ubuntu-firebase:latest
2. Jalankan containernya
Pergi ke folder project firebase kamu kemudian ketik command berikut ini untuk menjalankan container yang baru saja kita buatdocker run -it -v "$(pwd)":/data1 -p 9005:9005 ubuntu-firebase:latest
3. Menggunakan Firebase CLI
Jangan lupa login dulu untuk menggunakan firebase clifirebase login
cd data1
firebase use --add
4. Berhasil deh
Karena saya ingin menggunakan firebase function maka saya menginstall package yang dibutuhkannpm install
firebase serve --only functions -o 0.0.0.0 --port=9005
Tidak ada komentar:
Catatan: Hanya anggota dari blog ini yang dapat mengirim komentar.