Skip to content

Commit

Permalink
Feat:도커파일 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
wokbjso committed Dec 20, 2023
1 parent f11bd79 commit 25b6d1d
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM node:18 AS builder

# set working directory
WORKDIR /app


# install app dependencies

COPY package* yarn.lock .pnp* ./
COPY .yarnrc.yml ./
COPY .yarn ./.yarn

# Installs all node packages
RUN yarn install --immutable

# Copies everything over to Docker environment
COPY . .
RUN yarn build

#Stage 2
#######################################
#pull the official nginx:1.19.0 base image
FROM nginx
#copies React to the container directory
# Set working directory to nginx resources directory
# WORKDIR /usr/share/nginx/html
COPY config/nginx/default.conf /etc/nginx/conf.d/default.conf
# Remove default nginx static resources
RUN rm -rf ./usr/share/nginx/html/*
# Copies static resources from builder stage
COPY --from=builder /app/build /usr/share/nginx/html/
# Containers run nginx with global directives and daemon off
EXPOSE 3000
ENTRYPOINT ["nginx", "-g", "daemon off;"]
12 changes: 12 additions & 0 deletions config/nginx/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
server {
listen 3000;
root /usr/share/nginx/html;
index index.html;

location / {
try_files $uri /index.html;
}

error_log /var/log/nginx/api_error.log;
access_log /var/log/nginx/api_access.log;
}
3 changes: 3 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { defineConfig } from "vite";
import svgrPlugin from "vite-plugin-svgr";

export default defineConfig({
build: {
outDir: "build",
},
plugins: [react(), svgrPlugin()],
server: {
port: 3000,
Expand Down

0 comments on commit 25b6d1d

Please sign in to comment.