Add build step for Docker container

This commit is contained in:
Keannu Bernasol 2024-10-17 18:53:49 +08:00
parent 2ca1dc97f0
commit 9fcdac56cb
3 changed files with 46 additions and 0 deletions

19
.woodpecker/.build.yml Normal file
View file

@ -0,0 +1,19 @@
steps:
- name: build
image: node:18-alpine
when:
- branch: master
event: push
commands:
- docker build -t "$REGISTRY_IMAGE_TAG" .
- echo "$FORGEJO_REGISTRY_PASSWORD" | docker login "$FORGEJO_REGISTRY_URL" --password-stdin -u "$FORGEJO_REGISTRY_USERNAME"
- docker push "$FORGEJO_REGISTRY_URL"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
secrets:
[
FORGEJO_REGISTRY_URL,
FORGEJO_REGISTRY_USERNAME,
FORGEJO_REGISTRY_PASSWORD,
REGISTRY_IMAGE_TAG,
]

15
Dockerfile Normal file
View file

@ -0,0 +1,15 @@
FROM node:18-alpine as build
WORKDIR /usr/local/app
COPY ./ /usr/local/app/
RUN npm install
RUN chmod +x /usr/local/app/build.sh
RUN /usr/local/app/build.sh
FROM nginx:latest
RUN rm -rf /usr/share/nginx/html/*
COPY --from=build /usr/local/app/ /usr/share/nginx/html
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
RUN service nginx restart
EXPOSE 80

12
nginx/nginx.conf Normal file
View file

@ -0,0 +1,12 @@
server {
listen 80;
sendfile on;
default_type application/octet-stream;
gzip on;
root /usr/share/nginx/build;
location / {
try_files $uri $uri/ /index.html =404;
}
}