File size: 1,732 Bytes
d353019
 
51c6910
d353019
282c100
 
 
 
 
 
 
 
f0b42e2
8c13eae
 
 
206bd24
d353019
51c6910
 
 
693d472
51c6910
 
b9df4f3
 
 
51c6910
d353019
 
 
 
 
 
 
 
 
 
 
 
 
 
4a473dd
51c6910
 
 
b9df4f3
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Stage 1: Build and configure environment
FROM ubuntu:bionic AS build

# Install necessary packages and dependencies
RUN apt-get update && \
    apt-get install -y \
    xvfb \
    nginx \
    libxcursor1 \
    bash && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

# Create necessary directories with appropriate permissions
RUN mkdir -p /app/build /var/log/nginx /var/lib/nginx /var/cache/nginx /usr/share/nginx/html /usr/share/nginx/html-page && \
    chown -R www-data:www-data /var/log/nginx /var/lib/nginx /var/cache/nginx /usr/share/nginx/html /usr/share/nginx/html-page

# Copy backend server files and Nginx configuration
COPY build/ /app/build/
COPY etc/nginx/nginx.conf /etc/nginx/nginx.conf
COPY etc/nginx/conf.d /etc/nginx/conf.d
COPY webgl-build /usr/share/nginx/html
COPY html-page /usr/share/nginx/html-page

# Copy and configure custom entrypoint script
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

# Stage 2: Runtime
FROM nginx:alpine

# Copy the Nginx configuration and application from the build stage
COPY --from=build /etc/nginx/nginx.conf /etc/nginx/nginx.conf
COPY --from=build /etc/nginx/conf.d /etc/nginx/conf.d
COPY --from=build /usr/share/nginx/html /usr/share/nginx/html
COPY --from=build /usr/share/nginx/html-page /usr/share/nginx/html-page
COPY --from=build /app/build /app/build
COPY --from=build /entrypoint.sh /entrypoint.sh

# Ensure the correct permissions for directories
RUN mkdir -p /var/log/nginx /var/lib/nginx /var/cache/nginx && \
    chown -R www-data:www-data /var/log/nginx /var/lib/nginx /var/cache/nginx

# Expose necessary ports
EXPOSE 80 7777/udp 7778/tcp 7860

# Set the entrypoint to start the backend server and Nginx
ENTRYPOINT ["/entrypoint.sh"]