Skip to content

Commit 2a3acad

Browse files
committed
feat : Define Dockerfile & Docker Compose
- Dockerfile 내에서 `.env`을 복사하는 과정이 있기 때문에 `.dockerignore`에서 `.env*`를 제외했습니다.
1 parent e82f46a commit 2a3acad

File tree

3 files changed

+98
-0
lines changed

3 files changed

+98
-0
lines changed

.dockerignore

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files.
2+
3+
# Ignore git directory.
4+
/.git/
5+
/.gitignore
6+
/.gitattributes
7+
8+
# Ignore bundler config.
9+
/.bundle
10+
11+
# Ignore lint config
12+
/.rubocop.yml
13+
14+
# Ignore all logfiles and tempfiles.
15+
/log/*
16+
/tmp/*
17+
!/log/.keep
18+
!/tmp/.keep
19+
20+
# Ignore pidfiles, but keep the directory.
21+
/tmp/pids/*
22+
!/tmp/pids/.keep
23+
24+
# Ignore storage (uploaded files in development and any SQLite databases).
25+
/storage/*
26+
!/storage/.keep
27+
/tmp/storage/*
28+
!/tmp/storage/.keep
29+
30+
# Ignore CI service files.
31+
/.github
32+
33+
# Ignore development files
34+
/.devcontainer
35+
36+
# Ignore Docker-related files
37+
/.dockerignore
38+
/Dockerfile*
39+
40+
README.md

Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
ARG RUBY_VERSION=3.2.2
2+
FROM docker.io/library/ruby:$RUBY_VERSION-slim AS base
3+
4+
ARG ENV_FILE_PATH=.env
5+
COPY $ENV_FILE_PATH .env
6+
7+
WORKDIR /app
8+
9+
COPY . /app
10+
11+
RUN apt-get update -qq && \
12+
apt-get install --no-install-recommends -y curl libjemalloc2 libvips postgresql-client && \
13+
rm -rf /var/lib/apt/lists /var/cache/apt/archives
14+
15+
RUN apt-get update -qq && \
16+
apt-get install --no-install-recommends -y build-essential git libpq-dev pkg-config && \
17+
rm -rf /var/lib/apt/lists /var/cache/apt/archives
18+
19+
COPY Gemfile Gemfile.lock ./
20+
RUN bundle install
21+
22+
EXPOSE 8080
23+
CMD ["dotenv", "rails", "s", "-p", "8080"]

docker-compose.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
version: '3.8'
2+
3+
services:
4+
db:
5+
image: postgres:latest
6+
container_name: app-db
7+
restart: always
8+
ports:
9+
- "5432:5432"
10+
environment:
11+
- POSTGRES_USER=${DB_USERNAME}
12+
- POSTGRES_PASSWORD=${DB_PASSWORD}
13+
- POSTGRES_DB=schedule_reservation_system
14+
volumes:
15+
- postgres_data:/var/lib/postgresql/data
16+
17+
app:
18+
build:
19+
context: .
20+
args:
21+
ENV_FILE_PATH: ${ENV_FILE_PATH}
22+
container_name: schedule_reservation_system
23+
restart: always
24+
depends_on:
25+
- db
26+
ports:
27+
- "8080:8080"
28+
environment:
29+
- DB_NAME=schedule_reservation_system
30+
- DB_USERNAME=${DB_USERNAME}
31+
- DB_PASSWORD=${DB_PASSWORD}
32+
- DB_HOST=db
33+
34+
volumes:
35+
postgres_data:

0 commit comments

Comments
 (0)