I’ve been trying to create a container with my frontend on Vue, but when it is created, it immediately exits and is not running.
Here i show my Dockerfile:
# compliation
FROM node:latest as build-stage
WORKDIR /app
COPY ./app/package*.json ./
RUN npm install
COPY ./app .
RUN npm run build
# production
FROM httpd:latest as production-stage
WORKDIR /usr/local/apache2/
COPY --from=build-stage /app/dist/ htdocs/
COPY ./httpd.conf /usr/local/apache2/conf/httpd.conf
RUN chown -R www-data:www-data /usr/local/apache2/htdocs /usr/local/apache2/logs /usr/local/apache2/conf
RUN chmod -R 755 /usr/local/apache2/logs
EXPOSE 80
CMD ["httpd-foreground"]
And my docker-compose.yml file:
services:
frontend:
build:
context: ./
dockerfile: Dockerfile.prod
image: myapp-frontend:latest
ports:
- "8080:80"
networks:
- app-network
networks:
app-network:
driver: bridge
volumes:
mysql-data:
driver: local
The httpd configuration:
LoadModule mpm_event_module modules/mod_mpm_event.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule log_config_module modules/mod_log_config.so
ServerName localhost
DocumentRoot "/usr/local/apache2/htdocs"
<Directory "/usr/local/apache2/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
</Directory>
<IfModule mod_proxy.c>
ProxyPreserveHost On
ProxyPass /api http://backend:9000/api
ProxyPassReverse /api http://backend:9000/api
</IfModule>
ErrorLog /usr/local/apache2/logs/error.log
CustomLog /usr/local/apache2/logs/access.log combined
As i said, when creating the container, it exits immediately after its creation.
I tried creating the container from outside the folder, but the same problem occurs; it exits right after creating it.