This commit is contained in:
ondal 2025-02-15 13:15:05 +09:00
parent a867f21c53
commit 22981e4535
5 changed files with 180 additions and 92 deletions

59
container/Dockerfile Normal file
View File

@ -0,0 +1,59 @@
# Build stage
FROM node:20-slim AS builder
ARG PROJECT_FOLDER
ARG REACT_APP_MEMBER_URL
ARG REACT_APP_MYSUB_URL
ARG REACT_APP_RECOMMEND_URL
ENV NODE_ENV=production
WORKDIR /app
# Install dependencies
COPY ${PROJECT_FOLDER}/package*.json ./
RUN npm ci --only=production
# Build application
COPY ${PROJECT_FOLDER} .
RUN npm run build
# Run stage
FROM nginx:stable-alpine
# 시스템 환경변수 셋팅: api.js에서 사용하는 시스템 환경변수를 build시 셋팅해야 생성됨
ENV REACT_APP_MEMBER_URL=${REACT_APP_MEMBER_URL}
ENV REACT_APP_MYSUB_URL=${REACT_APP_MYSUB_URL}
ENV REACT_APP_RECOMMEND_URL=${REACT_APP_RECOMMEND_URL}
ARG BUILD_FOLDER
ARG EXPORT_PORT
# Create nginx user if it doesn't exist
RUN adduser -S nginx || true
# Copy build files
COPY --from=builder /app/build /usr/share/nginx/html
# Copy and process nginx configuration
COPY ${BUILD_FOLDER}/nginx.conf /etc/nginx/templates/default.conf.template
# Add custom nginx settings
RUN echo "client_max_body_size 100M;" > /etc/nginx/conf.d/client_max_body_size.conf
RUN echo "proxy_buffer_size 128k;" > /etc/nginx/conf.d/proxy_buffer_size.conf
RUN echo "proxy_buffers 4 256k;" > /etc/nginx/conf.d/proxy_buffers.conf
RUN echo "proxy_busy_buffers_size 256k;" > /etc/nginx/conf.d/proxy_busy_buffers_size.conf
# Set permissions
RUN chown -R nginx:nginx /usr/share/nginx/html && \
chmod -R 755 /usr/share/nginx/html && \
chown -R nginx:nginx /var/cache/nginx && \
chown -R nginx:nginx /var/log/nginx && \
chown -R nginx:nginx /etc/nginx/conf.d && \
touch /var/run/nginx.pid && \
chown -R nginx:nginx /var/run/nginx.pid
USER nginx
EXPOSE ${EXPORT_PORT}
CMD ["nginx", "-g", "daemon off;"]

29
container/nginx.conf Normal file
View File

@ -0,0 +1,29 @@
server {
listen 18080;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
# Cache static files
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 1y;
add_header Cache-Control "public, no-transform";
}
}
# Health check endpoint
location /health {
access_log off;
return 200 'healthy\n';
add_header Content-Type text/plain;
}
# Error pages
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}

8
package-lock.json generated
View File

@ -17224,16 +17224,16 @@
} }
}, },
"node_modules/typescript": { "node_modules/typescript": {
"version": "5.7.3", "version": "4.9.5",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
"integrity": "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==", "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==",
"peer": true, "peer": true,
"bin": { "bin": {
"tsc": "bin/tsc", "tsc": "bin/tsc",
"tsserver": "bin/tsserver" "tsserver": "bin/tsserver"
}, },
"engines": { "engines": {
"node": ">=14.17" "node": ">=4.2.0"
} }
}, },
"node_modules/unbox-primitive": { "node_modules/unbox-primitive": {

View File

@ -11,99 +11,99 @@ import {
import { Visibility, VisibilityOff } from '@mui/icons-material'; import { Visibility, VisibilityOff } from '@mui/icons-material';
const LoginForm = ({ onSubmit, error }) => { const LoginForm = ({ onSubmit, error }) => {
const [userId, setUserId] = useState(''); const [userId, setUserId] = useState('');
const [password, setPassword] = useState(''); const [password, setPassword] = useState('');
const [showPassword, setShowPassword] = useState(false); const [showPassword, setShowPassword] = useState(false);
const handleSubmit = (e) => { const handleSubmit = (e) => {
e.preventDefault(); e.preventDefault();
onSubmit(userId, password); onSubmit(userId, password);
}; };
return ( return (
<Box <Box
component="form" component="form"
onSubmit={handleSubmit} onSubmit={handleSubmit}
sx={{ sx={{
display: 'flex', display: 'flex',
flexDirection: 'column', flexDirection: 'column',
gap: 2, gap: 2,
width: '100%', width: '100%',
maxWidth: 400, maxWidth: 400,
margin: '0 auto' margin: '0 auto'
}} }}
> >
<Box <Box
sx={{ sx={{
display: 'flex', display: 'flex',
justifyContent: 'center', justifyContent: 'center',
mb: 3 mb: 3
}} }}
> >
<img <img
src="/images/logo192.png" src="/images/logo192.png"
alt="마이구독 로고" alt="마이구독 로고"
style={{ style={{
width: '100px', width: '100px',
height: '100px', height: '100px',
objectFit: 'contain' objectFit: 'contain'
}} }}
/> />
</Box> </Box>
<TextField <TextField
label="아이디" label="아이디"
variant="outlined" variant="outlined"
fullWidth fullWidth
value={userId} value={userId}
onChange={(e) => setUserId(e.target.value)} onChange={(e) => setUserId(e.target.value)}
error={!!error} error={!!error}
autoComplete="username" autoComplete="username"
required required
/> />
<TextField <TextField
label="비밀번호" label="비밀번호"
type={showPassword ? 'text' : 'password'} type={showPassword ? 'text' : 'password'}
variant="outlined" variant="outlined"
fullWidth fullWidth
value={password} value={password}
onChange={(e) => setPassword(e.target.value)} onChange={(e) => setPassword(e.target.value)}
error={!!error} error={!!error}
autoComplete="current-password" autoComplete="current-password"
required required
InputProps={{ InputProps={{
endAdornment: ( endAdornment: (
<InputAdornment position="end"> <InputAdornment position="end">
<IconButton <IconButton
onClick={() => setShowPassword(!showPassword)} onClick={() => setShowPassword(!showPassword)}
edge="end" edge="end"
> >
{showPassword ? <VisibilityOff /> : <Visibility />} {showPassword ? <VisibilityOff /> : <Visibility />}
</IconButton> </IconButton>
</InputAdornment> </InputAdornment>
), ),
}} }}
/> />
{error && ( {error && (
<Typography color="error" variant="body2"> <Typography color="error" variant="body2">
{error} {error}
</Typography> </Typography>
)} )}
<Button <Button
type="submit" type="submit"
variant="contained" variant="contained"
color="primary" color="primary"
size="large" size="large"
fullWidth fullWidth
sx={{ mt: 2 }} sx={{ mt: 2 }}
> >
로그인 로그인
</Button> </Button>
</Box> </Box>
); );
}; };
export default LoginForm; export default LoginForm;

View File