Hello, here are the documentation to build backend Docker image using Dockerfile.
**1. Preparing source code**
using backend source code the followed link below
[https://github.com/adaptivenetworklab/AN_OPEN_NETRA_BE](https://github.com/adaptivenetworklab/AN_OPEN_NETRA_BE)
**2. Create Dockerfile**
create Dockerfile that contain base image and several command to modify the image and inserted the frontend source code
```
FROM python:3
ENV PYTHONUNBUFFERED 1
COPY requirements.txt .
RUN pip install -r requirements.txt
RUN django-admin startproject AN_OPEN_NETRA_BE
COPY . /AN_OPEN_NETRA_BE
WORKDIR /AN_OPEN_NETRA_BE
ENV KUBECONFIG=/AN_OPEN_NETRA_BE/kube-config
EXPOSE 8000
CMD [ "python", "manage.py", "runserver", "0.0.0.0:8000" ]
```
newest update Dockerfile using ubuntu base image
```
FROM ubuntu:jammy
# install requirement dependencies
RUN apt update
RUN apt install python3 python3-pip curl -y
COPY requirements.txt .
RUN pip install -r requirements.txt
ENV TZ=Asia/Bangkok
COPY . .
# kubectl install
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd6>RUN chmod +x ./kubectl
RUN mv ./kubectl /usr/local/bin/kubectl
ENV KUBECONFIG=/kube-config
#helm install
RUN curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
RUN chmod +x get_helm.sh && ./get_helm.sh
#running service
EXPOSE 8000
CMD [ "python3", "manage.py", "runserver", "0.0.0.0:8000" ]
```
**3. Build image**
after the Dockerfile is ready, now build the Dockerfile using the command below:
```
$ docker build -t openetra/be .
```
the command will build the image with image output tag or name is openetra/be and we should specify the location of Dockerfile that is .
**4. Run image**
when the image from Dockerfile is ready, we can use the image to run the container with the command below:
```
$ docker run -it --name be -p 8088:8080 openetra/be
```
the output of running docker image has shown below:
