Skip to content

Instantly share code, notes, and snippets.

@LuckyArdhika
Last active October 22, 2023 09:51
Show Gist options
  • Save LuckyArdhika/fcaecdaeffc0eafe00debde9a0e97f96 to your computer and use it in GitHub Desktop.
Save LuckyArdhika/fcaecdaeffc0eafe00debde9a0e97f96 to your computer and use it in GitHub Desktop.
Dockerfile example
#~# Folder Structure
myapp/
├── backend/
│ ├── package.json
│ ├── server.js
│ └── (other backend files)
├── frontend/
│ ├── package.json
│ ├── index.html
│ └── (other frontend files)
└── Dockerfile
#~# Dockerfile
FROM node:14
# Instal dependensi untuk frontend
WORKDIR /app/frontend
COPY frontend/package*.json ./
RUN npm install
# Instal dependensi untuk backend
WORKDIR /app/backend
COPY backend/package*.json ./
RUN npm install
# Salin kode aplikasi
WORKDIR /app
COPY . .
# Atur port dan perintah untuk menjalankan frontend
WORKDIR /app/frontend
EXPOSE 3000
CMD ["npm", "start"]
# Atur port dan perintah untuk menjalankan backend
WORKDIR /app/backend
EXPOSE 5000
CMD ["npm", "start"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment