From ff0b28a0a771f90c641efac037c2b52f824f2a7c Mon Sep 17 00:00:00 2001 From: falconlee236 Date: Sat, 6 Jul 2024 13:12:11 +0000 Subject: [PATCH] add docker file --- Dockerfile | 15 +++++++++++++++ README.md | 13 +++++++++++++ src/main.cpp | 6 ++++-- start.sh | 5 +++++ 4 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 Dockerfile create mode 100644 start.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a168f18 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +#image +FROM debian:bookworm + +# command directory +WORKDIR /usr/src/irc_server + +RUN apt-get -qq update\ + && apt-get -qq install -y g++ make\ + && apt-get clean + +COPY . /usr/src/irc_server/ + +RUN chmod +x start.sh + +CMD [ "./start.sh" ] \ No newline at end of file diff --git a/README.md b/README.md index d9e6a0e..6c14c70 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,15 @@ # IRC_Server IRC Webserver based RFC1459 + + +### docker 접속 방법 +```bash +docker build --rm -t irc_server . +docker run -p 3000:3000 irc_server +``` +### docker 실행중인거 삭제 방법 +```bash +docker rm -f $(docker ps -qa) +``` + +`docker ps -qa`는 현재 실행하는 모든 컨테이너의 id를 출력 \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 42d294d..849eeac 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,6 @@ #include +#include +#include #include #include #include // inet_ntoa @@ -20,13 +22,13 @@ int main(void){ //NOTE - IPV$ socket address인 경우 sockaddr_in, 그 상위는 sockaddr // 서버 주소 설정하는 과정. struct sockaddr_in server_addr; - bzero(&server_addr, sizeof(server_addr)); + memset(&server_addr, 0, sizeof(server_addr)); // NOTE - 주소체계 : ipv4 server_addr.sin_family = AF_INET; // NOTE - INADDR_ANY 자신의 모든 랜카드로 ip를 받을 수 있음. server_addr.sin_addr.s_addr = htonl(INADDR_ANY); // NOTE - Server ip의 PORT번호 지정 - server_addr.sin_port = htons(8080); + server_addr.sin_port = htons(3000); // NOTE - socket과 ip를 연경하는 작업 int binded = bind(server_socket, (struct sockaddr *)&server_addr, sizeof(server_addr)); diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..524c12b --- /dev/null +++ b/start.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +make re +ls +./ircserv \ No newline at end of file