Skip to content

Commit

Permalink
Merge pull request #594 from Clubber2024/feat/#589-운영서버-해외-ip-차단-작업
Browse files Browse the repository at this point in the history
feat : cicd, docker-compose, dockerfile 생성 및 수정 (#589)
  • Loading branch information
sseongeun authored Jan 23, 2025
2 parents 5073310 + a08c305 commit b4045b2
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ jobs:
docker build -f Dockerfile.prod -t ${{ secrets.DOCKER_REPO }}/clubber-backend-prod .
docker push ${{ secrets.DOCKER_REPO }}/clubber-backend-prod
- name: docker build and push to prod nginx
if: contains(github.ref, 'main')
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -f Dockerfile.nginx.prod -t ${{ secrets.DOCKER_REPO }}/clubber-nginx-prod .
docker push ${{ secrets.DOCKER_REPO }}/clubber-nginx-prod
- name: Copy docker-compose.yml to EC2 DEV
if: contains(github.ref, 'dev')
uses: appleboy/scp-action@master
Expand Down Expand Up @@ -126,5 +133,6 @@ jobs:
sudo docker rm -f $(docker ps -qa)
sudo docker pull ${{ secrets.DOCKER_REPO }}/clubber-backend-prod
sudo docker pull ${{ secrets.DOCKER_REPO }}/clubber-front-prod
sudo docker pull ${{ secrets.DOCKER_REPO }}/clubber-nginx-prod
sudo docker-compose -f docker-compose-prod.yml up -d
sudo docker image prune -f
43 changes: 43 additions & 0 deletions Dockerfile.nginx.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Use the official NGINX base image
FROM nginx:1.24.0

# Install dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
wget \
curl \
build-essential \
libpcre3-dev \
zlib1g-dev \
libmaxminddb-dev \
git \
&& rm -rf /var/lib/apt/lists/*

# Download and extract NGINX source code
ARG NGINX_VERSION=1.24.0
WORKDIR /usr/src
RUN wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz && \
tar -zxvf nginx-${NGINX_VERSION}.tar.gz && \
rm nginx-${NGINX_VERSION}.tar.gz

# Clone ngx_http_geoip2_module
RUN git clone https://github.com/leev/ngx_http_geoip2_module.git

# Build NGINX with geoip2 module
WORKDIR /usr/src/nginx-${NGINX_VERSION}
RUN ./configure \
--with-compat \
--add-dynamic-module=../ngx_http_geoip2_module && \
make modules

# Copy the built module to the NGINX modules directory
RUN mkdir -p /usr/lib/nginx/modules/
RUN cp objs/ngx_http_geoip2_module.so /usr/lib/nginx/modules/

# Clean up
RUN apt-get purge -y --auto-remove \
wget \
curl \
build-essential \
git && \
rm -rf /usr/src/*
3 changes: 2 additions & 1 deletion docker-compose-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ services:

nginx:
container_name: nginx
image: nginx:latest
image: ssuclubber/clubber-nginx-prod
environment:
- TZ=Asia/Seoul
volumes:
- ./nginx/:/etc/nginx/
- ./data/certbot/conf:/etc/letsencrypt
- ./data/certbot/www:/var/www/certbot
- /var/lib/GeoIP/GeoLite2-Country.mmdb:/var/lib/GeoIP/GeoLite2-Country.mmdb
ports:
- "80:80"
- "443:443"
Expand Down

0 comments on commit b4045b2

Please sign in to comment.