mirror of
https://github.com/BZmHackTeam/BezpiecznaZywnosc
synced 2024-12-22 06:36:59 +01:00
Docker. (NPM START SCRIPT PENDING)
This commit is contained in:
parent
b77acdb322
commit
a5618d0301
5 changed files with 141 additions and 0 deletions
3
.dockerignore
Normal file
3
.dockerignore
Normal file
|
@ -0,0 +1,3 @@
|
|||
**/obj/
|
||||
**/bin/
|
||||
**/node_modules
|
69
Dockerfile
Normal file
69
Dockerfile
Normal file
|
@ -0,0 +1,69 @@
|
|||
FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine AS build
|
||||
|
||||
RUN apk add npm
|
||||
|
||||
WORKDIR /source
|
||||
|
||||
COPY src/Nyanlabs.SFood.UI/sfood/package*.json src/Nyanlabs.SFood.UI/sfood/
|
||||
|
||||
RUN
|
||||
|
||||
COPY Nyanlabs.SFood.sln ./
|
||||
|
||||
COPY src/Nyanlabs.SFood.Api/*.csproj ./src/Nyanlabs.SFood.Api/
|
||||
COPY src/Nyanlabs.SFood.UI/*.csproj ./src/Nyanlabs.SFood.UI/
|
||||
COPY test/Nyanlabs.SFood.Test/*.csproj ./test/Nyanlabs.SFood.Test/
|
||||
|
||||
RUN dotnet restore
|
||||
|
||||
COPY src/Nyanlabs.SFood.Api/. ./src/Nyanlabs.SFood.Api/
|
||||
COPY src/Nyanlabs.SFood.UI/. ./src/Nyanlabs.SFood.UI/
|
||||
|
||||
RUN dotnet test --no-restore
|
||||
|
||||
RUN dotnet publish ./src/Nyanlabs.SFood.Api/ -c Release -o /build/api
|
||||
RUN dotnet publish ./src/Nyanlabs.SFood.UI/ -c Release -o /build/ui
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:7.0-alpine AS api
|
||||
|
||||
# Files
|
||||
|
||||
COPY --from=build /build/api /srv
|
||||
|
||||
VOLUME [ "/srv/log" ]
|
||||
|
||||
WORKDIR /srv
|
||||
|
||||
ENV ASPNETCORE_ENVIRONMENT=Production
|
||||
|
||||
# Net
|
||||
|
||||
EXPOSE 80/tcp
|
||||
|
||||
# Process handling
|
||||
|
||||
STOPSIGNAL SIGTERM
|
||||
|
||||
ENTRYPOINT [ "dotnet", "/srv/Nyanlabs.SFood.Api.dll" ]
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:7.0-alpine AS ui
|
||||
|
||||
# Files
|
||||
|
||||
COPY --from=build /build/ui /srv
|
||||
|
||||
VOLUME [ "/srv/log" ]
|
||||
|
||||
WORKDIR /srv
|
||||
|
||||
ENV ASPNETCORE_ENVIRONMENT=Production
|
||||
|
||||
# Net
|
||||
|
||||
EXPOSE 80/tcp
|
||||
|
||||
# Process handling
|
||||
|
||||
STOPSIGNAL SIGTERM
|
||||
|
||||
ENTRYPOINT [ "dotnet", "/srv/Nyanlabs.SFood.UI.dll" ]
|
4
dev.Caddyfile
Normal file
4
dev.Caddyfile
Normal file
|
@ -0,0 +1,4 @@
|
|||
http://localhost {
|
||||
reverse_proxy /api/* http://sfood_api:80
|
||||
reverse_proxy http://sfood_ui:80
|
||||
}
|
32
dev.Dockerfile
Normal file
32
dev.Dockerfile
Normal file
|
@ -0,0 +1,32 @@
|
|||
FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine as base
|
||||
|
||||
EXPOSE 80/tcp
|
||||
EXPOSE 443/tcp
|
||||
|
||||
ENV USERNAME=meowie
|
||||
ENV USER_UID=1000
|
||||
ENV USER_GID=1001
|
||||
|
||||
RUN addgroup -g $USER_GID $USERNAME \
|
||||
&& adduser -u $USER_UID -G $USERNAME -D $USERNAME
|
||||
|
||||
RUN mkdir -p /srv/log
|
||||
RUN chown -R $USERNAME:$USERNAME /srv/log
|
||||
|
||||
VOLUME [ "/srv/log" ]
|
||||
|
||||
STOPSIGNAL SIGKILL
|
||||
|
||||
WORKDIR /source
|
||||
|
||||
FROM base AS api
|
||||
|
||||
USER $USERNAME
|
||||
ENTRYPOINT [ "dotnet", "watch", "--project", "./src/Nyanlabs.SFood.Api", "run", "--", "--urls", "http://0.0.0.0:80" ]
|
||||
|
||||
FROM base AS ui
|
||||
|
||||
RUN apk add npm
|
||||
|
||||
USER $USERNAME
|
||||
ENTRYPOINT [ "dotnet", "watch", "--project", "./src/Nyanlabs.SFood.UI", "run", "--", "--urls", "http://0.0.0.0:80" ]
|
33
docker-compose.yml
Normal file
33
docker-compose.yml
Normal file
|
@ -0,0 +1,33 @@
|
|||
version: "3"
|
||||
|
||||
services:
|
||||
ui:
|
||||
container_name: sfood_ui
|
||||
image: docker.femsci.net:5000/sfood_ui:dev
|
||||
build:
|
||||
context: ./
|
||||
dockerfile: dev.Dockerfile
|
||||
target: ui
|
||||
volumes:
|
||||
- ./:/source
|
||||
environment:
|
||||
- ASPNETCORE_ENVIRONMENT=Development
|
||||
api:
|
||||
container_name: sfood_api
|
||||
image: docker.femsci.net:5000/sfood_api:dev
|
||||
build:
|
||||
context: ./
|
||||
dockerfile: dev.Dockerfile
|
||||
target: api
|
||||
volumes:
|
||||
- ./:/source
|
||||
environment:
|
||||
- ASPNETCORE_ENVIRONMENT=Development
|
||||
rp:
|
||||
container_name: caddy
|
||||
image: caddy:alpine
|
||||
ports:
|
||||
- 80:80
|
||||
- 443:443
|
||||
volumes:
|
||||
- ./dev.Caddyfile:/etc/caddy/Caddyfile
|
Loading…
Reference in a new issue