Skip to content

Commit

Permalink
add docker file
Browse files Browse the repository at this point in the history
  • Loading branch information
falconlee236 committed Jul 6, 2024
1 parent bec40b8 commit ff0b28a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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를 출력
6 changes: 4 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h> // inet_ntoa
Expand All @@ -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));
Expand Down
5 changes: 5 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

make re
ls
./ircserv

0 comments on commit ff0b28a

Please sign in to comment.