Skip to content

Commit

Permalink
config init.sql
Browse files Browse the repository at this point in the history
  • Loading branch information
phuuthanh-dev committed Jun 7, 2024
1 parent ab902fe commit a6ffac6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
12 changes: 11 additions & 1 deletion db/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
# Dùng official SQL Server 2019 image của Microsoft
FROM mcr.microsoft.com/mssql/server:2019-latest

# Biến môi trường
ENV ACCEPT_EULA=Y
ENV SA_PASSWORD=Thanhth@nh1

COPY init.sql /docker-entrypoint-initdb.d/init.sql
# Copy the SQL script vào container
COPY init.sql /usr/src/app/init.sql

# Chạy lệnh trong file sql
RUN /opt/mssql/bin/sqlservr & sleep 30 \
&& /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P $SA_PASSWORD -i /usr/src/app/init.sql \
&& pkill sqlservr

EXPOSE 1433
# Khởi động sql server
CMD ["/opt/mssql/bin/sqlservr"]
20 changes: 12 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
version: '3.0'

services:
auction-database:
image: ghcr.io/phuuthanh2003/auction-database:latest
ports:
- "1433:1433"
environment:
SA_PASSWORD: "Thanhth@nh1"
ACCEPT_EULA: "Y"

auction-api:
image: ghcr.io/phuuthanh2003/auction-api:latest
ports:
- "8085:8080"
- "8080:8080"
depends_on:
- auction-database

auction-database:
image: ghcr.io/phuuthanh2003/auction-database:latest
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=Thanhth@nh1
ports:
- "1433:1433"
SPRING_DATASOURCE_URL: jdbc:sqlserver://auction-database:1433;encrypt=true;trustServerCertificate=true;databaseName=DB_AUCTION;
SPRING_DATASOURCE_USERNAME: sa
SPRING_DATASOURCE_PASSWORD: Thanhth@nh1

0 comments on commit a6ffac6

Please sign in to comment.