File tree Expand file tree Collapse file tree
sample_solutions/CodeTranslation Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,6 +11,13 @@ RUN pip install --no-cache-dir -r requirements.txt
1111# Copy application code
1212COPY . .
1313
14+ # Create a non-root user and change ownership
15+ RUN useradd -m -u 1000 appuser && \
16+ chown -R appuser:appuser /app
17+
18+ # Switch to non-root user
19+ USER appuser
20+
1421# Expose port
1522EXPOSE 5001
1623
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ services:
3434 dockerfile : Dockerfile
3535 container_name : code-trans-frontend
3636 ports :
37- - " 3000:80 "
37+ - " 3000:8080 "
3838 depends_on :
3939 - backend
4040 networks :
Original file line number Diff line number Diff line change @@ -24,6 +24,18 @@ COPY --from=build /app/dist /usr/share/nginx/html
2424# Copy nginx configuration
2525COPY nginx.conf /etc/nginx/conf.d/default.conf
2626
27- EXPOSE 80
27+ # Create a non-root user and adjust permissions
28+ RUN adduser -D -u 1000 appuser && \
29+ chown -R appuser:appuser /usr/share/nginx/html && \
30+ chown -R appuser:appuser /var/cache/nginx && \
31+ chown -R appuser:appuser /var/log/nginx && \
32+ chown -R appuser:appuser /etc/nginx/conf.d && \
33+ touch /var/run/nginx.pid && \
34+ chown -R appuser:appuser /var/run/nginx.pid
35+
36+ # Switch to non-root user
37+ USER appuser
38+
39+ EXPOSE 8080
2840
2941CMD ["nginx" , "-g" , "daemon off;" ]
Original file line number Diff line number Diff line change 11server {
2- listen 80 ;
2+ listen 8080 ;
33 server_name localhost;
44 root /usr/share/nginx/html;
55 index index .html;
You can’t perform that action at this time.
0 commit comments